Reading What's the difference between shell builtin and shell keyword? I wondered how much I could alias stuff in the shell.
So for example instead of writing
string_with_spaces='some spaces here'
if [ -n $string_with_spaces ]; then
echo "The string is non-empty"
fi
the challenge would be to to write something like
signvico='iuj spacetoj tie ĉi'
se ja nevakua $signvico plie vera ope nu tiam
echo "la signvico ne estas vakua!"
eme
So I tried this
alias se='if'
alias tiam='then'
alias eme='fi'
alias ja='['
alias ope=']'
alias nevakua='-n'
alias vera='true'
alias plie='-a'
alias nu=';'
alias eĥu='echo'
But that won't work. Indeed, using -a
, -n
, ;
and ]
aliases will make the script fail. Using se ja -n $signvico -a vera ] ; tiam
with the rest of the above code will work however. I guess it's all due to the corresponding code being parsed/substituted at different level of the interpreter pipeline.
But is there a way to indeed make the whole code above as expected?