Mailing List Archive
tlug.jp Mailing List tlug archive tlug Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]Re: [tlug] Strange shell quoting issue
- Date: Thu, 21 Jun 2007 23:31:54 +0900
- From: Mattia Dongili <malattia@example.com>
- Subject: Re: [tlug] Strange shell quoting issue
- References: <d8fcc0800706210536w30bae9dawc0432abe9c5f147f@mail.gmail.com>
- User-agent: Mutt/1.5.13 (2006-08-11)
On Thu, Jun 21, 2007 at 09:36:16PM +0900, Josh Glover wrote: > Shell gurus, why does this not work? > > > : jglover@example.com; cat `which sync-script` > > RSYNC="rsync -e ssh -av --exclude .\*" > > echo ${RSYNC} ./ somehost.example.com:/some/dir/ > ${RSYNC} ./ somehost.example.com:/some/dir/ Funny, see: $ cat /tmp/script #!/bin/sh RSYNC='rsync -av --exclude ".*"' echo ${RSYNC} A/ B $RSYNC A/ B $ cd /tmp && ls -a A B A: total 8 drwxr-xr-x 2 mattia mattia 16 2007-06-21 22:32 . drwxrwxrwt 14 root root 4096 2007-06-21 22:56 .. -rw-r--r-- 1 mattia mattia 0 2007-06-21 22:32 .NO -rw-r--r-- 1 mattia mattia 0 2007-06-21 22:32 YES B: total 8 drwxr-xr-x 2 mattia mattia 1 2007-06-21 22:56 . drwxrwxrwt 14 root root 4096 2007-06-21 22:56 .. $ sh -x /tmp/script + RSYNC='rsync -av --exclude ".*"' + echo rsync -av --exclude '".*"' A/ B rsync -av --exclude ".*" A/ B + rsync -av --exclude '".*"' A/ B building file list ... done ./ .NO YES sent 186 bytes received 70 bytes 512.00 bytes/sec total size is 0 speedup is 0.00 WFT^2?? '".*"' ?? and you can get even fancier results with all the tests you listed... or even try something different than bash (I tried zsh and dash and you don't want to see the output)... A workaround (without still understanding what happened except that quoting when assigning variables is randomized) is: eval ${RSYNC} A/ B or wrap the command differently: function rsync_with_opts () { rsync -av --exclude ".*" "$1" "$2" } rsync_with_opts "A/" "B" Sorry I can't be of more help, but looking at others script the 'eval' thing seems preferred :) -- mattia :wq!
- References:
- [tlug] Strange shell quoting issue
- From: Josh Glover
Home | Main Index | Thread Index
- Prev by Date: [tlug] Re: Denshi Jisho
- Next by Date: [tlug] Re: [OT?]A Hard Drive Question
- Previous by thread: Re: [tlug] Strange shell quoting issue
- Next by thread: [tlug] Re: Denshi Jisho
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links