[Top][All Lists]

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

Re: aliasing "sed" to "sed --posix"

From: Bruce Korb
Subject: Re: aliasing "sed" to "sed --posix"
Date: Mon, 06 Aug 2007 07:53:26 -0700
User-agent: Thunderbird (X11/20060911)

Bruno Haible wrote:
> Bruce Korb wrote:
>> Aliases are turned off.
>> Below is an experiment.  Invoke with and without an argument.  The results
>> look like this:
> Your experiment uses the 'exit' command to test whether aliases are supported.
> However, 'exit' is a shell built-in. Whereas 'sed' is not and will likely
> never be a shell built-in. Can you retry your experiment with a non-built-in?
> In gnulib-tool line 468 you see that the usual way to override built-ins in
> bash is to define them as a function, because 'alias' does not work for them.

Hi Bruno,

Well, I knew ahead of writing the script that unless the shopt
expand_aliases were turned on that they would not work.  I had
stumbled into this before.  I experimented with aliasing "exit"
because it would have a dramatic effect on the execution flow. :)
Sure enough, if I aliased "exit" to the echo, the echo fired
and I had demonstrated my point:  if you want to ensure that
"sed" is run with "--posix", then either ensure that aliases
are expanded within the script, or else use a function.  This
is true whether you are aliasing sed or, apparently, exit.

Cheers - Bruce

reply via email to

[Prev in Thread] Current Thread [Next in Thread]