[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bash messes up spaces in command line agruments.

From: Herrmann, Justin
Subject: Bash messes up spaces in command line agruments.
Date: Tue, 6 May 2008 09:20:07 -0500

Configuration Information [Automatically generated, do not change]:
Machine: i486
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i486'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i486-pc-linux-gnu'
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash'
-DSHELL -DHAVE_CONFIG_H   -I.  -I../bash -I../bash/include -I../bash/lib
-g -02 -Wall
uname output: Linux justin-desktop 2.6.22-14-generic #1 SMP Tue Feb 12
07:42:25 UTC 2008 i686 GNU/Linux
Machine Type: i486-pc-linux-gnu

Bash Version: 3.2
Patch Level: 25
Release Status: release

Description: When I try to pass strings inside double or single quotes
as command line arguments to my Bash script, leading spaces, trailing
spaces, and multiple grouped embedded spaces are removed from the
string.  This also prevents me from passing in only a space or spaces as
arguments to my script.

Repeat-By: Save this script as 'startup':

echo $#
for ((index = 0; index <= $#; index++))
        echo "$index |$(eval echo \${$index})|"
exit 0

then type: ./startup '     some       words          '

the script will print out:
0 |./startup|
1 |some words|

reply via email to

[Prev in Thread] Current Thread [Next in Thread]