Changes with provided user's source code transform (Size and performance efficient rewriting of the `dash.test` built-in)

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

 



In light of my last LKML posts about text processing of
(still plain text and open) source http://kernelnewbies.org/olecom
i'd like to propose slightly improved maintaining of changes.

In this particular case, it is providing `sed` transformation of

' -a ' , ' -o '
to
' ] && [ ' , ' ] || [ '


along with change in built-in `test`. Note again, that -a -o are optional
(due to problems) in POSIX.

# http://www.opengroup.org/onlinepubs/009695399/utilities/test.html :

test "$1" -a "$2"

     should be written as:
test "$1" && test "$2"

     to avoid problems if a user supplied values such as $1 set to '!'
     and $2 set to the null string. That is, in cases where maximal
     portability is of concern, replace:
test expr1 -a expr2

     with:
test expr1 && test expr2

     and replace:
test expr1 -o expr2

     with:
test expr1 || test expr2
----
As usual, there is an unnoticeable "but":
----
     but note that, in test, -a has higher precedence than -o while "&&"
     and "||" have equal precedence in the shell.
#end

I wonder if any user of those operands knew this, also i can't
understand those "precedence" rules here. It's just even more confusing.


== original proposition for -nt -ot (specifying lists of files to check) ==

Fri, Oct 19, 2007 at 09:51:21PM +0200:

> > _Optimization_, i.e. to do not call stat() on the same file on and on.
> > This is just silly.
> 
> This is called "userspace sucks" by kernel people, isn't it?

Some of those got knocked out (having nothing technical to say) by regexp
ninja, i am. http://kerneltrap.org/node/16091


Here's error, however.

> Square braces [' && ]' proposed, because they not require escaping
> from the shell.

Unquoted '[' is the file-name pattern class introduction character.
____
--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux