Fw: [clug] beginners path

Daniel Pittman daniel at rimspace.net
Sun Apr 26 01:13:50 GMT 2009


steve jenkin <sjenkin at canb.auug.org.au> writes:

[...]

> commands use similar syntax because of 'getopt'/'getopts'. There is a
> library and a bash inbuilt if you're scripting.

I would probably explain this to people more like this:

    Most commands handle arguments in a similar fashion because they use
    a common library, or something designed to be compatible with it.

    Not everything does, though, so you will occasionally come across
    something that looks like the same option handling but doesn't work
    like that.  The documentation for the program should explain how
    things do work, though.

The main reason for that extra detail is that find(1) is terribly
confusing to people who associate getopt and the '-foo' argument syntax,
since it looks similar but is actually very, very different. :/


If they were coming from a DOS-enough background — which is vanishingly
rare, these days, in my experience — to actually care I might also
append this extra, and critical, information:

    The biggest difference in starting programs comes when you give them
    an argument that matches multiple files, like '*.*'.

    Under DOS the program is just told that you wanted '*.*', and has
    the responsibility of doing something sensible with it — and most of
    them do, but it can be pretty different.

    Under Unix things are different: the shell actually turns '*.*' into
    a list of files, then passes that to the program — so, everything
    behaves consistently when run from the same shell.

    This matters because if you manage to pass the '*.*' to the command
    without expanding it then it will probably surprise you:

    ] ls *.*
    a.text
    b.ods
    ] ls '*.*'
    ls: cannot access *.*: No such file or directory

[...]

> Unix/Posix used a single-dash. GNU introduced '--option' (and --help).
> try both:
>  'command -?' and
>  'command --help'

On a Linux platform I would probably treat the GNU options as standard,
because that is true enough that it won't confuse.  Introduce the Unix
differences later, because most folks won't run into them for some
time, if ever.

[...]

> Finally, the most talented & productive programmer/admin I ever worked
> with (never worked with Tridge) had a very simple & powerful 'trick'
> that made him much more effective than others:
>
>  - when he learnt something arcane or created something useful,
>    he wrote himself a note, categorised and kept it.
>
> In 1994, he used an organiser that he carried with him. Even had a
> serial cable so he could upload more complex shell scripts etc.
> Not sure what he does now.
>
> He organised his notes to suit his style & memory, and captured just
> 'the essence' - notes for his personal use, not general doco. These
> sorts of notes have value in their creation - laying down strong
> 'traces' for recall.

Now, *this* is good advice. :)

Regards,
        Daniel


More information about the linux mailing list