gzip tries to unpack/pack 1st the filename of $GZIP

Devin Teske dteske at vicor.com
Thu Oct 14 16:04:46 UTC 2010


On Thu, 2010-10-14 at 16:48 +0200, Matthias Apitz wrote:
> El día Thursday, October 14, 2010 a las 10:39:13AM -0400, Lowell Gilbert escribió:
> 
> > Matthias Apitz <guru at unixarea.de> writes:
> > 
> > > Hello,
> > >
> > > I was facing a problem in some Makefile/shell-scripting and finally I
> > > could nail it down:
> > >
> > > when you set the environment variable GZIP to something, for example to
> > > let it point to gzip itself, it tries 1st to unpack this file:
> > >
> 	...
> 
> This was my fault. I overlooked it in the man page. SOrry;
> 
> > You need to fix the syntax on your 'export' lines.
> > Adding a semicolon before the "export" keyword (or
> > moving it to the next line) is the smallest change 
> > to do this.
> 
> Why?
> 
> $ FIX=foo export FIX
> $ env | fgrep FIX
> FIX=foo
> 
> 	matthias
> 

I'm with matthias on this one...

Here's the technical explanation:

When performing assignment in bourne/again shell, if the right-hand side
of the assignment (=) does not begin with either a single-quote or
double-quote, spaces will terminate the assignment and begin a new
command.

For example:

abc=123 echo hello, world
       ^
       |
end of assignment (start of new command; imagine implied semi-colon)

This produces two distinct commands:

1. abc=123
2. echo hello world


Contrast that with either:

abc="123 echo hello world"

or

abc=123\ echo\ hello,\ world

Both of which succeed in assigning `123 echo hello, world' to variable
`abc'.


Pop Quiz: What does the following do:

abc=123\ xyz echo hello

Answer:

1. assigns `123 xyz' to variable `abc'
2. executes: echo hello

Second Pop Quiz:

abc="123 xyz" echo hello

Answer:

1. assigns `123 xyz' to variable `abc'
2. executes: echo hello


This obviously doesn't work in tennex/c shell:

# echo $0 $SHELL
-csh /bin/csh
# abc=123
abc=123: Command not found.
# ls -li `which csh tcsh`
1411 -r-xr-xr-x  2 root  wheel  651964 Jan 23  2007 /bin/csh
1411 -r-xr-xr-x  2 root  wheel  651964 Jan 23  2007 /bin/tcsh

-- 
Cheers,
Devin Teske

-> CONTACT INFORMATION <-
Business Solutions Consultant II
FIS - fisglobal.com
510-735-5650 Mobile
510-621-2038 Office
510-621-2020 Office Fax
909-477-4578 Home/Fax
devin.teske at fisglobal.com

-> LEGAL DISCLAIMER <-
This message  contains confidential  and proprietary  information
of the sender,  and is intended only for the person(s) to whom it
is addressed. Any use, distribution, copying or disclosure by any
other person  is strictly prohibited.  If you have  received this
message in error,  please notify  the e-mail sender  immediately,
and delete the original message without making a copy.

-> END TRANSMISSION <-



More information about the freebsd-questions mailing list