[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: why does this define bla() instead of respect the newline as command
From: |
Robert Elz |
Subject: |
Re: why does this define bla() instead of respect the newline as command separator |
Date: |
Fri, 19 Mar 2021 16:23:55 +0700 |
Date: Fri, 19 Mar 2021 09:12:34 +0100
From: Alex fxmbsw7 Ratchev <fxmbsw7@gmail.com>
Message-ID:
<CAALKErGCNx4JdkK1+tDKvdtgdwLTDB+ZtLZQp35f2Wwx_YqT2A@mail.gmail.com>
| eval $'alias n=bla\nn() { type $FUNCNAME ; }\nn'
| bla is a function
| bla ()
| {
| type $FUNCNAME
| }
|
| it was supposed to be n() ..
nothing to do with the \n that woukd have
worked just fine.
the first command in the eval'd string
aluan n=blah
t tekks the shell that whever it sees n on
the command name position itshoukd be replaved
by blah
Next command starts n ...
That's the command word position, so because
of the alias, you get blah instead. aliases
are a very low level textual substitution
mechanism.
After that I suspect everything is obvious.
I suggest that if you want to learn shell
programming (and learning is obviousky required)
you should start with the simple things first.
Definitely leave aliases and associative arrays
for some later year. And remember the purpose
of the shell (any shell) is to run other commands.
If that is not what you're wanting to do, you
should be using some other programming language.
There are plenty. Find one suited to your needs
and learn/use that instead.
kre