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

Re: view_attachment script query



On Sun  9.Dec'07 at 17:15:38 -0600, Kyle Wheeler wrote:
> 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
That's great thanks very much, i'll give a try now. 

Jamie 

Attachment: pgp2uMo3lbTKV.pgp
Description: PGP signature