bug-bash
[Top][All Lists]
Advanced

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

Re: RFE & RFC: testing executability


From: L A Walsh
Subject: Re: RFE & RFC: testing executability
Date: Sun, 01 Oct 2017 23:32:50 -0700
User-agent: Thunderbird



Pierre Gaston wrote:


Besides the fact that most people don't use alias in script
---
   That's due to bash being non-POSIX compatible, by default in regard to
aliases. Aliases are designed to "always be there" and always be "on" unless
explicitly turned off so people could rely on them.  Set -e was changed to
apply to complex & compound statements rather than the result of simple
command.  It was said this was forced to be true in non-posix compat mode
because it would be easier to maintain.  Looking at the code --
it would be simplified as well if aliases were always on.  So will it be
changed?
where it would be the only place where such a feature would really be valuable,
----
   Don't people use functions? Aren't functions executable code?


I think the main problem is that alias can contain pretty much anything, from loops, partial code etc..
---
   That's not a problem.  Of course you know how bash puts it's aliases
in a HASH called BASH_ALIASES, as I stated, the value would be tested for
executability.


What should be the result of -x in the  following case?

alias f='for i in 1 2;do echo foo;done'
The value of the BASH_ALIASES[f] would be tested for executability.


alias g='if true; then'
alias h='true;missing_command'

Should it be recursive?
-----
No more or less than aliases already are recursive.
alias j=f

In my opinion the feature you describe is pretty much tailored to your specific need but it is probably hard to give it a really more general and sensible meaning.
----
The meaning was already clear. Anything in bash that is already executable
should read "true" when -x is used with it.

   How else do you parse:

if -x grep ; then ... fi...

So that it is the same whenever grep is executable?

How can a script writer know that they will get false if it is an
alias or function -- even if grep is there.  That's counter intuitive
since the script writer wouldn't expect grep to not be executable if
it is there because and alias or function doing the same thing is
still something that is executable.







reply via email to

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