Re: bash scripting question (variables and spaces)
Karsten Heymann <karsten.heymann@gmx.de> writes:
> Hi,
>
> I have once again come upon bash problem I can't solve. I'm writing
> a little bash frontend and one of the programs expects a option that
> includes spaces and is composed from two other shell var's. Example:
>
> #!/bin/bash
> A="Hello"
> B="Karsten"
> C=$A $B
> someprog --greeting $C
You need something like
#!/bin/sh
A=Hello
B=Karsten
C="$A $B"
someprog --greeting "$C"
Without the quotes, the shell expands things to
someprog --greeting Hello Karsten
which then gets turned into arguments "someprog", "--greeting",
"Hello", "Karsten"; presumably someprog only reads a single argument
after --greeting, and gets just "Hello".
--
David Maze dmaze@debian.org http://people.debian.org/~dmaze/
"Theoretical politics is interesting. Politicking should be illegal."
-- Abra Mitchell
Reply to: