On Sat 04 Mar 2023 at 20:52:15 (+1100), David wrote:

> Hi. Friends don't help friends to do bad things :)
> 
> Debian's default shell is 'dash'. Its manual, readable using 'man dash',
> says
> 
>     Aliases provide a convenient way for naive users to create shorthands
>     for commands without having to learn how to create functions with
>     arguments.

IMHO manpages should be about function, not policy. I don't like
this condescension. man bash   is more straightforward:

  For almost every purpose, aliases are superseded by shell functions.

> They can also be used to create lexically obscure code.

What has that got to do with the price of fish?

In view of the Obfuscated Perl Contest, is the author railing
against writing anything in Perl?

>     This use is discouraged

There's a place for warning about the use of aliases in, say,
Greg's BashPitfalls, or books, but not here.

> To achieve your goal, do this instead.
> 
> In .bash_profile, replace the line
>   alias k='minikube kubectl --'
> 
> with these two lines:
>   k() { minikube kubectl "$@" ; }
>   export k

Overkill for those I've written. And I would discourage the use
of that sort of shortcut function anywhere else but interactively.
Exporting it and then using it in scripts is going to produce
code that's just as lexically obscure.

I guess it falls to me to provide some examples of mine:

  alias 1234='printf AmexD\\n'

Redacted; one of several. (I don't have an American Express card.)

  alias cal='ncal -3 -A1'

For me, cal output needs transposing. This range is so useful.

  alias cdeject='eject # mask cdeject which produces I/O error and locks up 
drive'

From the days when I played red-book CDs at work.

  alias hekspace='od -t a -t x1 -An'

Can anyone memorise all those switches.

  alias py='python3'

A sophisticated calculator.

  alias tnef='tnef -v --directory ~/Documents --number-backups'

Curse MS Exchange's attachments.

Finally, I'm not arguing against manpage warnings like this:

  --drq-hsm-error
    VERY DANGEROUS, DON'T EVEN THINK ABOUT USING IT. …
    … VERY DANGEROUS, DO NOT USE!! 

  (man hdparm)

that guard against accidental bricking.

Cheers,
David.

Reply via email to