From: Niall O Broin (niall at domain linux.ie)
Date: Tue 30 Apr 2002 - 09:16:37 IST
Take the trivial bash script shown which I'll call echo.sh
#!/bin/bash
echo $1
and pass it an argument with spaces in e.g.
echo.sh "a b c d"
and the output will be
a b c d
i.e. all the repeated spaces are compressed to one space.
Take the equally trivial Perl script which I'll call echo.pl
#!/usr/bin/perl
print "$ARGV[0]\n";
and pass it the same argument as above e.g.
echo.pl "a b c d"
and the output will be
a b c d
I've just spent the last 4 hours trying to debug this thinking that it was a
bug in Pure-FTPD [Pure-FTPD has the facility that it can run a program
whenever a file is uploaded. It does this by writing details of the uploaded
file to a pipe which pipe is then read by a companion program, which spawns
the processing program of your choice for every uploaded file. The program
spawned is passed the path to the uploaded file.
Well, as I hadn't used this facility before I was trying it out and in my
stupidity as a test program I had a shell script something like the above
and I discovered this space squashing problem. I assumed it was a problem
with Pure-FTPD and eventaully came to the conclusion that the problem had to
be in execl, which seemed a little unlikely. Then the Gods decided to take
pity on me and inspired me to do some command line experiments with such
areguments to a shell script.
To add to the sillyness, leading or trailing spaces to a shell script's
arguments are removed altogether.
So, is this a Bash bug or just a feature I don't understand ?
Niall
This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:16:28 GMT