Skip to Content.
Sympa Menu

sm-sorcery-bugs - [SM-Sorcery-Bugs] [Bug 6539] handling of bash variables with spaces

sm-sorcery-bugs AT lists.ibiblio.org

Subject: Bugs for Sorcery are reported here

List archive

Chronological Thread  
  • From: bugzilla-daemon AT metalab.unc.edu
  • To: sm-sorcery-bugs AT lists.ibiblio.org
  • Subject: [SM-Sorcery-Bugs] [Bug 6539] handling of bash variables with spaces
  • Date: Sat, 3 Apr 2004 16:10:39 -0500

http://bugs.sourcemage.org/show_bug.cgi?id=6539





------- Additional Comments From acedit AT armory.com 2004-04-03 16:10 -------
i really dont think that fixes the problem as bash just makes the quotes go
away
when it fills in the variable and then on the command line it still looks like
two seperate words.

Have you confirmed that just quoting the variables actually fixes the problem?

I think the real solution is to adjust IFS. Ive been playing around with some
code:
t.sh resets IFS to just the newline
s.sh doesnt
I've made a file with spaces in it "foo bar"

afrayedknot@thefrayedknot:/tmp/junk2$ ls -l
total 8
-rw-r--r-- 1 afrayedknot afrayedknot 0 Apr 3 12:50 foo bar
-rwxr-xr-x 1 afrayedknot afrayedknot 40 Apr 3 13:06 s.sh
-rwxr-xr-x 1 afrayedknot afrayedknot 48 Apr 3 13:07 t.sh
afrayedknot@thefrayedknot:/tmp/junk2$ cat s.sh
while read each ; do md5sum $each; done
afrayedknot@thefrayedknot:/tmp/junk2$ ls|s.sh
md5sum: foo: No such file or directory
md5sum: bar: No such file or directory
8c47b5c75e396b5c5efa47f03b851cca s.sh
28dffea01c5441ee3f1bdf31214331a0 t.sh
afrayedknot@thefrayedknot:/tmp/junk2$ cat t.sh
IFS="
"
while read each ; do md5sum $each; done
afrayedknot@thefrayedknot:/tmp/junk2$ ls|t.sh
d41d8cd98f00b204e9800998ecf8427e foo bar
8c47b5c75e396b5c5efa47f03b851cca s.sh
28dffea01c5441ee3f1bdf31214331a0 t.sh
afrayedknot@thefrayedknot:/tmp/junk2$


notice how the
IFS="
"
incantation solves the problem?

to do this in sorcery, simply save IFS in a local variable
adjust it as above, run through the function
then reset it before leaving.



------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.




Archive powered by MHonArc 2.6.24.

Top of Page