[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: how execute a script



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

On Tue, Nov 17, 2015 at 11:08:46PM +0000, Brian wrote:
> On Tue 17 Nov 2015 at 21:41:01 +0100, Luis Felipe Tabera Alonso wrote:
> 
> > On Tuesday 17 November 2015 20:21:23 Brian wrote:
> > > 
> > > I've also asked for a *concrete example* of a program not opening a file
> > > because of the lack of an extension. It hasn't yet been given.
> > 
> > $ gunzip file 
> > gzip: file: unknown suffix -- ignored

Here, gunzip is seeing the file name. Since gzip, by convention, removes
the original (and gunzip the compressed), effectively replacing each by
the other), those programs are extra careful. The file name pattern is
part of the interface specification.

> That is a good example.
> 
>   brian@desktop:~$ cp /etc/services test
>   brian@desktop:~$ file test
>   test: ASCII text
> 
>   brian@desktop:~$ gzip test
> 
>   brian@desktop:~$ file test.gz 
>   test.gz: gzip compressed data, was "test", last modified: Tue Nov 17 21:49:33 2015, from Unix
> 
>   brian@desktop:~$ mv test.gz test-1
> 
> test-1 has no extension. Does gzip have two personalities? :)
> 
>   brian@desktop:~$ gunzip < test-1 > test-2

Here, gunzip works as a filter. It doesn't even *see* the file name,
the shell opens the file for it (because of the <) and feeds its
content via gunzip's stdin.

Same case as upthread with tab completion. It's very important to
think carefully what the program "sees" and what the shell is doing
for it.

>   brian@desktop:~$ file test-2 
>   test-2: ASCII text
> 
> Interesting. gunzip will decompress a file without an extension. Does it
> have two personalities? :)
> 
> Alternatively:
> 
>   zcat test-1 > test-2 

Zcat, zless and co behave like cat & less with a prepended unzip filter.

> > $mv file other.gz
> > $gunzip other.gz 
> > $ls
> > other
> 
>   $mv file other.
>   $gunzip -S . other.
>   $ls
>   other
> 
> gunzip is a tool that does seem to care what the files are named.

And that makes sense. In a way yes, it has two personalities: an
"in-place" (de) compressor and a filter. The first one enforces a
file pattern convention because it's (potentially) deleting stuff.

Not that I personally like the in-place thing, mind you. I guess
it was born out of necessity: if you are zipping a file which is
much bigger than what you've space left on device, this interface
makes sense.

- -- t
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAlZMLS8ACgkQBcgs9XrR2kaxzgCeLEa3vyEZYoKvPdNkJ+k7rSDl
hTsAn0dsH9+ygZsvk4wgzGdQQ8fXgX4r
=Q/Iq
-----END PGP SIGNATURE-----


Reply to: