Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #160720

Re: how execute a script

From <tomas@tuxteam.de>
Newsgroups linux.debian.user
Subject Re: how execute a script
Date 2015-11-18 09:30 +0100
Message-ID <qw6hP-nn-9@gated-at.bofh.it> (permalink)
References <qvkZB-3jF-5@gated-at.bofh.it> <qvUA1-Xn-9@gated-at.bofh.it> <qvV33-1oM-9@gated-at.bofh.it> <qvVFN-1Tz-13@gated-at.bofh.it> <qvXxU-36Y-29@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


-----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-----

Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Re: how execute a script Martin Str|mberg <ams@ludd.luth.se> - 2015-11-16 07:00 +0100
  Re: how execute a script Chris Bannister <cbannister@slingshot.co.nz> - 2015-11-16 07:30 +0100
  Re: how execute a script David Wright <deblis@lionunicorn.co.uk> - 2015-11-16 20:40 +0100
    Re: how execute a script Lisi Reisz <lisi.reisz@gmail.com> - 2015-11-16 23:40 +0100
      Re: how execute a script <tomas@tuxteam.de> - 2015-11-17 09:30 +0100
      Re: how execute a script shawn wilson <ag4ve.us@gmail.com> - 2015-11-17 15:40 +0100
        Re: how execute a script Chris Bannister <cbannister@slingshot.co.nz> - 2015-11-17 19:10 +0100
          Re: how execute a script shawn wilson <ag4ve.us@gmail.com> - 2015-11-17 19:10 +0100
            Re: how execute a script Elimar Riesebieter <riesebie@lxtec.de> - 2015-11-17 19:30 +0100
              Re: how execute a script shawn wilson <ag4ve.us@gmail.com> - 2015-11-17 20:10 +0100
            Re: how execute a script Brian <ad44@cityscape.co.uk> - 2015-11-17 20:00 +0100
              Re: how execute a script shawn wilson <ag4ve.us@gmail.com> - 2015-11-17 20:10 +0100
                Re: how execute a script Brian <ad44@cityscape.co.uk> - 2015-11-17 21:00 +0100
                Re: how execute a script shawn wilson <ag4ve.us@gmail.com> - 2015-11-17 21:00 +0100
                Re: how execute a script shawn wilson <ag4ve.us@gmail.com> - 2015-11-17 21:10 +0100
                Re: how execute a script shawn wilson <ag4ve.us@gmail.com> - 2015-11-17 21:20 +0100
                Re: how execute a script <tomas@tuxteam.de> - 2015-11-17 22:00 +0100
                Re: how execute a script shawn wilson <ag4ve.us@gmail.com> - 2015-11-17 22:20 +0100
                Re: how execute a script tomas@tuxteam.de - 2015-11-17 23:10 +0100
                Re: how execute a script shawn wilson <ag4ve.us@gmail.com> - 2015-11-17 23:20 +0100
                Re: how execute a script shawn wilson <ag4ve.us@gmail.com> - 2015-11-17 23:30 +0100
                Re: how execute a script tomas@tuxteam.de - 2015-11-18 09:10 +0100
                Re: how execute a script John Hasler <jhasler@newsguy.com> - 2015-11-17 22:40 +0100
                Re: how execute a script Brian <ad44@cityscape.co.uk> - 2015-11-17 21:30 +0100
                Re: how execute a script Luis Felipe Tabera Alonso <taberalf@unican.es> - 2015-11-17 22:10 +0100
                Re: how execute a script Brian <ad44@cityscape.co.uk> - 2015-11-18 00:10 +0100
                Re: how execute a script Don Armstrong <don@debian.org> - 2015-11-18 01:10 +0100
                Re: how execute a script <tomas@tuxteam.de> - 2015-11-18 09:30 +0100
                Re: how execute a script David Wright <deblis@lionunicorn.co.uk> - 2015-11-18 16:00 +0100
                Re: how execute a script <tomas@tuxteam.de> - 2015-11-18 16:20 +0100
                Re: how execute a script David Wright <deblis@lionunicorn.co.uk> - 2015-11-18 16:40 +0100
              Re: how execute a script David Wright <deblis@lionunicorn.co.uk> - 2015-11-17 21:20 +0100
              Re: how execute a script <tomas@tuxteam.de> - 2015-11-17 22:00 +0100
                Re: how execute a script Brian <ad44@cityscape.co.uk> - 2015-11-18 00:10 +0100
                Re: how execute a script <tomas@tuxteam.de> - 2015-11-18 09:30 +0100
                Re: how execute a script Brian <ad44@cityscape.co.uk> - 2015-11-18 13:50 +0100
          Re: how execute a script <tomas@tuxteam.de> - 2015-11-17 19:20 +0100

csiph-web