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

Re: how execute a script



On Sat 14 Nov 2015 at 08:00:20 (+0100), tomas@tuxteam.de wrote:
> On Fri, Nov 13, 2015 at 09:11:34AM -0600, David Wright wrote:
> > On Fri 13 Nov 2015 at 14:43:39 (+0100), tomas@tuxteam.de wrote:
> > 
> > > (as an aside: it's bad custom inherited from DOS to name shell scripts
> > > with an .sh ending. No ending is the right thing here).
> > 
> > So these were all DOS scripts once, were they?
> > 
> > -rwxr-xr-x 1 root root 1248 Apr 21  2014 /etc/init.d/bootmisc.sh*
> > -rwxr-xr-x 1 root root 3807 Apr 21  2014 /etc/init.d/checkfs.sh*
> 
> [...]
> 
> Very smart. I didn't say the scripts are inherited from DOS. That bad
> habit is, definitely.

Well file extensions in general are of course much older than DOS
(assuming you mean MSDOS-compatible rather than the old meaning as in,
say, DOS/360 etc), going back to the origins of unix and further.

As for script-file extensions in DOS, there was really only .BAT
wasn't there?, so the idea of distinguishing .bash, .csh, .py, .pl,
.sh, .zsh etc as being inherited from DOS is difficult for me to
understand. I have no idea what was going through the head of whoever
christened /etc/init.d/hostname.sh originally.

> > I name my scripts in ~/bin with an extension corresponding to their
> > contents: .pl .py .sh etc. Where I'm working on alternative versions,
> > I might have more than one language. Extensionless filenames are
> > either links or binaries. What's bad about this? Or is it just
> > snobbery: Look, we don't need extensions.
> 
> No. If you call your scripts from other places, and -- say -- change
> the implementation from shell to ruby: do you have to run around and
> fix all the call sites? Have fun.

Of course I don't. Just write a foo.rb script, and when happy with it,
move the link to point at it. Above, you just quoted my saying
"Extensionless filenames are either links or binaries."

> The one case where an "extension" (as you call it: DOS, see?)

"Extension" is a generally understood shorthand that's been around for
years. Should we go through man pages such as gzip and change the word
to "suffix"? Or we could go back to using the language of dmr, as in:
'Arguments whose names end with ".c" are assumed to be C source
programs; they are compiled, and the object program is left on the
file sfile.o (i.e. the file whose name is that of the source with ".o"
substituted for ".c").'

> might
> make sense (I'd say a hint in the filename) is when your script isn't
> an executable in itself but a collection of functions you *source*
> from another shell: this so-called "shell library" has to be shell
> code (i.e. you can't change implementation).

Well, yes, that's frequently recommended in such cases.

> And snobbery? Pthttht.

Well, I'm just trying to find a motive for your condemnation, the use
of words like "right thing" and "bad", and your conviction that it's
all down to DOS (not just the phenomenon but even the word I used to
describe it).

I've never distributed a library, but have read about distributions
being packaged with file extensions, these then being stripped off at
installation time. As already explained in this thread, I achieve
the same effect with a link. I don't have enough scripts to have a
separate archive all packaged up and with an installation script, but
I want to be able to see the various scripting languages without
having to open the files themselves.

Say I want to see how many python scripts are still using a module
that I'm eliminating. I type grep ... ~/bin/*py just as I would if
python was a compiled language, rather than testing every file in
~/bin/* with file to discover its source language.

Cheers,
David.


Reply to: