Sprak
September 23rd, 2011, 10:21 AM
Hi!
I've run into a strange problem regarding a small shell script:
#! /bin/sh
FIRSTPATH=/first/path/
SECONDPATH=/second/path/
echo Line 1: Only first: "$FIRSTPATH"
echo Line 2: First: "$FIRSTPATH" Second: "$SECONDPATH"
echo Line 3: Second: "$SECONDPATH" First: "$FIRSTPATH"
And the output I get when running the file is:
me@sprak:~$ ./bug_in_bash.sh
Line 1: Only first: /first/path/
Second: /second/path/path/
Line 3: Second: /second/path/ First: /first/path/
I have a standard 32-bits Natty installation:
me@sprak:~$ uname -a
Linux sprak 2.6.38-11-generic #48-Ubuntu SMP Fri Jul 29 19:05:14 UTC 2011 i686 athlon i386 GNU/Linux
me@sprak:~$ cat /etc/issue
Ubuntu 11.04 \n \l
me@sprak:~$ bash -version
GNU bash, version 4.2.8(1)-release (i686-pc-linux-gnu)
Copyright (C) 2011 Free Software Foundation, Inc.
Licens GPLv3+: GNU GPL version 3 eller senare <http://gnu.org/licenses/gpl.html>
Why doesn't the 6th line in the script (
echo Line 2: First: "$FIRSTPATH" Second: "$SECONDPATH"
) yield the result
Line 2: First: /first/path/ Second: /second/path/?
Please, is there anyone who know what might be wrong or has encountered something similar before?
PS.
Perhaps it can help with some mor information:
If i run the script with "#! /bin/sh -x" instead then I get the following output:
+ FIRSTPATH=/first/path/
+ SECONDPATH=/second/path/
+ echo Line 1: Only first: /first/path/
Line 1: Only first: /first/path/
+ echo Line 2: First: /first/path/ Second: /second/path/
Line 2: First: /first/path/ Second: /second/path/
+ echo Line 3: Second: /second/path/ First: /first/path/
Line 3: Second: /second/path/ First: /first/path/
DS.
I've run into a strange problem regarding a small shell script:
#! /bin/sh
FIRSTPATH=/first/path/
SECONDPATH=/second/path/
echo Line 1: Only first: "$FIRSTPATH"
echo Line 2: First: "$FIRSTPATH" Second: "$SECONDPATH"
echo Line 3: Second: "$SECONDPATH" First: "$FIRSTPATH"
And the output I get when running the file is:
me@sprak:~$ ./bug_in_bash.sh
Line 1: Only first: /first/path/
Second: /second/path/path/
Line 3: Second: /second/path/ First: /first/path/
I have a standard 32-bits Natty installation:
me@sprak:~$ uname -a
Linux sprak 2.6.38-11-generic #48-Ubuntu SMP Fri Jul 29 19:05:14 UTC 2011 i686 athlon i386 GNU/Linux
me@sprak:~$ cat /etc/issue
Ubuntu 11.04 \n \l
me@sprak:~$ bash -version
GNU bash, version 4.2.8(1)-release (i686-pc-linux-gnu)
Copyright (C) 2011 Free Software Foundation, Inc.
Licens GPLv3+: GNU GPL version 3 eller senare <http://gnu.org/licenses/gpl.html>
Why doesn't the 6th line in the script (
echo Line 2: First: "$FIRSTPATH" Second: "$SECONDPATH"
) yield the result
Line 2: First: /first/path/ Second: /second/path/?
Please, is there anyone who know what might be wrong or has encountered something similar before?
PS.
Perhaps it can help with some mor information:
If i run the script with "#! /bin/sh -x" instead then I get the following output:
+ FIRSTPATH=/first/path/
+ SECONDPATH=/second/path/
+ echo Line 1: Only first: /first/path/
Line 1: Only first: /first/path/
+ echo Line 2: First: /first/path/ Second: /second/path/
Line 2: First: /first/path/ Second: /second/path/
+ echo Line 3: Second: /second/path/ First: /first/path/
Line 3: Second: /second/path/ First: /first/path/
DS.