bash ignores escaped $ and says "bad substitution"


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting bash ignores escaped $ and says "bad substitution"
# 1  
Old 10-22-2009
bash ignores escaped $ and says "bad substitution"

Can someone tell me how to get the version of bash that I am running?

I'm running cygwin bash on Windows XP at home and cygwin bash on Vista at work.

Is this the version number for bash?
$ uname -a
CYGWIN_NT-6.0 US-SEA-L3BER9K 1.5.25(0.156/4/2) 2008-06-12 19:34 i686 Cygwin

This is the version at work that does not work.

Here is the command that works at home but not at work:

Code:
$ groovy -e " (new XmlSlurper().parse('languages.xml')).language.each { println \"\${it.@name} authored by \${it.author[0].text()}\" } "
/cygdrive/c/Program Files/Groovy/Groovy-1.6.4/bin/startGroovy: line 229: ${it.author[0].text()}" } ": bad substitution

Now who is complaining about the substitution: bash or groovy?

Why is bash complaining about a bad substitution? I escaped the "$" so bash would ignore it and this works at home. I tried "\\$" but that did not help! I want groovy to do the substitution, not bash.

The bash at work is a recent installation (August 2009). The bash at home was last updated a while ago, maybe spring 2009?

Hmmm... now that I am re-reading my own post I'm wondering if this is a groovy issue, not a bash issue. I'm trying to figure how how to delete this post...

Thanks,
Siegfried

Last edited by siegfried; 10-22-2009 at 03:14 PM..
# 2  
Old 10-22-2009
Hi.

You should be able to get the bash version by using

Code:
bash --version

uname has nothing to do with the version of bash. It shows information about the kernel revision, etc.

I would say that groovy is the one complaining, because you've quoted the string, and escaped everything else, there is no reason why bash should complain.

Simple test (sorry, I don't have groovy):
Code:
X=" (new XmlSlurper().parse('languages.xml')).language.each { println \"\${it.@name} authored by \${it.author[0].text()}\" } "
(no error)

echo $X

(new XmlSlurper().parse('languages.xml')).language.each { println "${it.@name} authored by ${it.author[0].text()}" }


Last edited by Scott; 10-22-2009 at 03:52 PM..
# 3  
Old 10-22-2009
Have you checked for illegal characters?

I know it may seem odd, but I got a similar error having dumped a script from Red Hat to Vista, edited it and passed it back again; CR/LF issues with the SCP transfer.

If you 'cat -vet' the file on both systems, does the output look the same?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

2. Shell Programming and Scripting

Explaining behaviour of sudo bash "$0" "$@";

I've found this script part on the stackoverflow: if ; then sudo bash "$0" "$@"; exit "$?"; fi I realized that sudo bash "$0" "$@"; is the only needed for me. But the strange thing happens when I move this line outside the IF statement: sudo bash "$0" "$@"; stops the... (9 Replies)
Discussion started by: boqsc
9 Replies

3. UNIX for Dummies Questions & Answers

"Help with bash script" - "License Server and Patch Updates"

Hi All, I'm completely new to bash scripting and still learning my way through albeit vey slowly. I need to know where to insert my server names', my ip address numbers through out the script alas to no avail. I'm also searching on how to save .sh (bash shell) script properly.... (25 Replies)
Discussion started by: profileuser
25 Replies

4. Shell Programming and Scripting

awk: Force "escaped" representation of a field

Is there any way to get the escaped version of a field in awk? For those that don't understand the question, here is a clarifying example. Lets say a field $1 gives me the string "(dumb'" (I've changed the delimiter to be something other than whitespace). If i use that value in a command in awk... (2 Replies)
Discussion started by: IvanMalison
2 Replies

5. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

6. Shell Programming and Scripting

Simplify Bash Script Using "sed" Or "awk"

Input file: 2 aux003.net3.com error12 6 awn0117.net1.com error13 84 aux008 error14 29 aux001.ha.ux.isd.com error12 209 aux002.vm.ux.isd.com error34 21 alx0027.vm.net2.com error12 227 dux001.net5.com error123 22 us008.dot.net2.com error121 13 us009.net2.com error129Expected Output: 2... (4 Replies)
Discussion started by: sQew
4 Replies

7. Solaris

Help:"Bad checksum in disk label" and "Can't open disk label package"?

Hello, I'm brand new to Sun/Solaris. I have a Sun Blade 150, with SunOS 5.8. I wanted to make a backup to prevent future data loss, so I put the disk in a normal PC with Windows XP to try to make a backup with Norton Ghost, the disk was detected, but not the file volume, so I place the disk... (6 Replies)
Discussion started by: Resadija
6 Replies

8. Shell Programming and Scripting

read -p "prompt text" foo say "read: bad option(s)" in Bourne-Shell

Hallo, i need a Prompting read in my script: read -p "Enter your command: " command But i always get this Error: -p: is not an identifier When I run these in c-shell i get this error /usr/bin/read: read: bad option(s) How can I use a Prompt in the read command? (9 Replies)
Discussion started by: wiseguy
9 Replies

9. Shell Programming and Scripting

Difference between "Command substitution" and "Process substitution"

Hi, What is the actual difference between these two? Why the following code works for process substitution and fails for command substitution? while IFS= read -r line; do echo $line; done < <(cat file)executes successfully and display the contents of the file But, while IFS='\n' read -r... (3 Replies)
Discussion started by: royalibrahim
3 Replies

10. Solaris

Big UH-OH "Bad magic number in disk label"

I tried rebooting my Sun server just a few minutes ago and I got the following at boot: -- Sun Fire 280R (UltraSPARC-III+) , No Keyboard Copyright 1998-2002 Sun Microsystems, Inc. All rights reserved. OpenBoot 4.5, 1024 MB memory installed, Serial #xxxxxxxxx Ethernet address... (6 Replies)
Discussion started by: deckard
6 Replies
Login or Register to Ask a Question