|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hi all,
I have a problem with variable expansion. I tried this with the bash: OPTIONS="-e 'ssh host ssh' -PHS" # In one config file rsync $OPTIONS ... # in a script 'source'-ing the config file The actual command and arguments are not the problem here, only that the -e option has an argument with spaces 'ssh host ssh'. After expanding OPTIONS the single quotes around this argument are not taken into account by the shell, i.e the command doesn't get that as one string but as three words: Arguments to command: -e, 'ssh, host, ssh', -PHS, not: -e, 'ssh host ssh', -PHS Because of this the options are parsed wrong by the command. Is there a way to keep the quoted part of the OPTIONS variable as one string? This trick seems to work but I look for something more general and better: OPTIONS="-e,ssh host ssh,-PHS" IFS="," rsync $OPTIONS ... |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
Martin wrote:
> Hi all, > > I have a problem with variable expansion. I tried this with the bash: > > OPTIONS="-e 'ssh host ssh' -PHS" # In one config file > > rsync $OPTIONS ... # in a script 'source'-ing the config file > > The actual command and arguments are not the problem here, only that > the -e option has an argument with spaces 'ssh host ssh'. > After expanding OPTIONS the single quotes around this argument are not > taken into account by the shell, i.e the command doesn't get that as > one string but as three words: > Arguments to command: -e, 'ssh, host, ssh', -PHS, not: -e, 'ssh host > ssh', -PHS > Because of this the options are parsed wrong by the command. > > Is there a way to keep the quoted part of the OPTIONS variable as one > string? > > This trick seems to work but I look for something more general and > better: > > OPTIONS="-e,ssh host ssh,-PHS" > > IFS="," > rsync $OPTIONS ... > eval rsync "$OPTIONS" -- Michael Tosch @ hp : com |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
Michael Tosch wrote:
> Martin wrote: > > Hi all, > > > > I have a problem with variable expansion. I tried this with the bash: > > > > OPTIONS="-e 'ssh host ssh' -PHS" # In one config file > > > > rsync $OPTIONS ... # in a script 'source'-ing the config file > > > > eval rsync "$OPTIONS" > Thanks, this works fine. I should have known this by myself! Martin |
|
![]() |
| Outils de la discussion | |
|
|