<<< Date Index >>>     <<< Thread Index >>>

Re: view_attachment script query



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sunday, December  9 at 11:10 PM, quoth Jamie Griffin:
>Firstly, it's working and the attachments are oping succesfully. 
>However, after i've closed it and return to mutt
>there's an error message on the command line which says: 
>/usr/local/bin/view_attachment: line 122: [: too many arguments

Probably insufficient quoting somewhere.

>here is line the part of the script from line 122:
>
>if [ -z $open_with ]; then

There's your problem. That should be:

     if [ -z "$open_with" ]; then

The reason is that if your open_with path has any spaces in it (which 
"Microsoft Word" does), it will be treated as multiple arguments to 
the test. What your really want is just to treat the whole thing as a 
single string, and that's what surrounding it in double-quotes 
ensures.

>    open $newfile
>else
>    open -a "$open_with" $newfile
>fi
>
>
>The fact it's working fine is good, of course, but this has bothered 
>me. Does anyone know why this is? perhaps i should remove the 
>argument? 

The reason it's working fine is that when the test fails (because of 
the incorrect quoting), all that happens is that the "else" portion is 
triggered, which is what you wanted to happen in the first place 
(since you're specifying an "open_with" argument).

~Kyle
- -- 
I know that there are people who do not love their fellow man, and I 
hate people like that!
                                                          -- Tom Lehrer
-----BEGIN PGP SIGNATURE-----
Comment: Thank you for using encryption!

iD8DBQFHXHcaBkIOoMqOI14RAhroAJ9KGIk+gdvfUG4uAASzSMPiLrtdCgCgpEra
nrlC0Cu6JcA+gBX1hZloFGo=
=ywd+
-----END PGP SIGNATURE-----