freebsd-skq/bin/sh
Ralf S. Engelschall f7d95a075c Various small code cleanups resulting from a code reviewing
and linting procedure:

1. Remove useless sub-expression:

   - if (*start || (!ifsspc && start > string && (nulonly || 1))) {
   + if (*start || (!ifsspc && start > string)) {

   The sub-expression "(nulonly || 1)" always evaluates to true and
   according to CVS logs seems to be just a left-over from some
   debugging and introduced by accident. Removing the sub-expression
   doesn't change semantics and a code inspection showed that the
   variable "nulonly" is also not necessary here in any way (and the
   expression would require fixing instead of removing).

2. Remove dead code:

   -                if (backslash && c == '\\') {
   -                        if (read(STDIN_FILENO, &c, 1) != 1) {
   -                                status = 1;
   -                                break;
   -                        }
   -                        STPUTC(c, p);
   -                } else if (ap[1] != NULL && strchr(ifs, c) != NULL) {
   +                if (ap[1] != NULL && strchr(ifs, c) != NULL) {

   Inspection of the control and data flow showed that variable
   "backslash" is always false (0) when the "if"-expression is
   evaluated, hence the whole block is effectively dead code.
   Additionally, the skipping of characters after a backslash is already
   performed correctly a few lines above, so this code is also not
   needed at all. According to the CVS logs and the ASH 0.2 sources,
   this code existed in this way already since its early days.

3. Cleanup Style:

   - ! trap[signo][0] == '\0' &&
   + ! (trap[signo][0] == '\0') &&

   The expression wants to ensure the trap is not assigned the empty
   string. But the "!" operator has higher precedence than "==", so the
   comparison should be put into parenthesis to form the intended way of
   expression. Nevertheless the code was effectively not really broken
   as both particular NUL comparisons are semantically equal, of course.
   But the parenthesized version is a lot more intuitive.

4. Remove shadowing variable declaration:

   - char *q;

   The declaration of symbol "q" hides another identical declaration of
   "q" in the same context. As the other "q" is already reused multiple
   times and also can be reused again without negative side-effects,
   just remove the shadowing declaration.

5. Just small cosmetics:

   - if (ifsset() != 0)
   + if (ifsset())

   The ifsset() macro is already coded by returning the boolean result
   of a comparison operator, so no need to compare this boolean result
   again against a numerical value. This also aligns the macros usage to
   the remaining existing code.

Reviewed by: stefanf@
2005-09-06 19:30:00 +00:00
..
bltin Declare echocmd() and testcmd(). 2005-08-13 15:04:30 +00:00
funcs /*- or .\"- or #- to begin license clauses. 2005-01-10 08:39:26 +00:00
alias.c Return 1 from the unalias builtin if _any_ removal fails, not just the last 2005-09-02 22:43:28 +00:00
alias.h Remove clause 3 from the UCB licenses. 2004-04-06 20:06:54 +00:00
arith_lex.l cvs -d stefanf@ncvs.FreeBSD.org:/home/ncvs 2005-08-13 07:54:23 +00:00
arith.h cvs -d stefanf@ncvs.FreeBSD.org:/home/ncvs 2005-08-13 07:54:23 +00:00
arith.y cvs -d stefanf@ncvs.FreeBSD.org:/home/ncvs 2005-08-13 07:54:23 +00:00
builtins.def /*- or .\"- or #- to begin license clauses. 2005-01-10 08:39:26 +00:00
cd.c Remove clause 3 from the UCB licenses. 2004-04-06 20:06:54 +00:00
cd.h Remove clause 3 from the UCB licenses. 2004-04-06 20:06:54 +00:00
error.c Remove clause 3 from the UCB licenses. 2004-04-06 20:06:54 +00:00
error.h Remove clause 3 from the UCB licenses. 2004-04-06 20:06:54 +00:00
eval.c Print pointers with %p rather than casting them to long. 2005-09-05 17:57:19 +00:00
eval.h Remove clause 3 from the UCB licenses. 2004-04-06 20:06:54 +00:00
exec.c Use prototypes in the MKINIT lines collected by mkinit. 2005-08-13 08:12:18 +00:00
exec.h Remove clause 3 from the UCB licenses. 2004-04-06 20:06:54 +00:00
expand.c Various small code cleanups resulting from a code reviewing 2005-09-06 19:30:00 +00:00
expand.h Remove clause 3 from the UCB licenses. 2004-04-06 20:06:54 +00:00
histedit.c El_parse's third parameter is now const-qualified, add a cast. 2005-08-11 20:28:26 +00:00
init.h Remove clause 3 from the UCB licenses. 2004-04-06 20:06:54 +00:00
input.c Remove clause 3 from the UCB licenses. 2004-04-06 20:06:54 +00:00
input.h Remove clause 3 from the UCB licenses. 2004-04-06 20:06:54 +00:00
jobs.c Print pointers with %p rather than casting them to long. 2005-09-05 17:57:19 +00:00
jobs.h Remove clause 3 from the UCB licenses. 2004-04-06 20:06:54 +00:00
mail.c Include missing headers. 2005-08-13 08:26:58 +00:00
mail.h Remove clause 3 from the UCB licenses. 2004-04-06 20:06:54 +00:00
main.c Remove clause 3 from the UCB licenses. 2004-04-06 20:06:54 +00:00
main.h Remove clause 3 from the UCB licenses. 2004-04-06 20:06:54 +00:00
Makefile Recent cleanups made it possible to bump WARNS to 3. 2005-08-14 07:46:56 +00:00
memalloc.c Remove clause 3 from the UCB licenses. 2004-04-06 20:06:54 +00:00
memalloc.h Remove clause 3 from the UCB licenses. 2004-04-06 20:06:54 +00:00
miscbltin.c Various small code cleanups resulting from a code reviewing 2005-09-06 19:30:00 +00:00
mkbuiltins Use prototypes in the generated builtins.{c,h} files. 2005-08-13 08:09:22 +00:00
mkinit.c - Provide all initialisers for a struct event. 2005-08-13 08:38:02 +00:00
mknodes.c Remove clause 3 from the UCB licenses. 2004-04-06 20:06:54 +00:00
mksyntax.c Put the comparison with PEOF into a new macro is_eof(). Don't use it if the 2005-08-13 15:47:13 +00:00
mktokens /*- or .\"- or #- to begin license clauses. 2005-01-10 08:39:26 +00:00
myhistedit.h Remove clause 3 from the UCB licenses. 2004-04-06 20:06:54 +00:00
mystring.c Remove clause 3 from the UCB licenses. 2004-04-06 20:06:54 +00:00
mystring.h Remove clause 3 from the UCB licenses. 2004-04-06 20:06:54 +00:00
nodes.c.pat Remove clause 3 from the UCB licenses. 2004-04-06 20:06:54 +00:00
nodetypes /*- or .\"- or #- to begin license clauses. 2005-01-10 08:39:26 +00:00
options.c A second attempt to adjust option-parsing on a shell command, for the 2005-05-16 04:32:41 +00:00
options.h Remove clause 3 from the UCB licenses. 2004-04-06 20:06:54 +00:00
output.c Remove clause 3 from the UCB licenses. 2004-04-06 20:06:54 +00:00
output.h Remove clause 3 from the UCB licenses. 2004-04-06 20:06:54 +00:00
parser.c Remove a hack for an ancient gdb. 2005-08-15 17:49:38 +00:00
parser.h Remove clause 3 from the UCB licenses. 2004-04-06 20:06:54 +00:00
redir.c Remove clause 3 from the UCB licenses. 2004-04-06 20:06:54 +00:00
redir.h Remove clause 3 from the UCB licenses. 2004-04-06 20:06:54 +00:00
sh.1 fix typo: ommitted -> omitted 2005-09-06 16:08:37 +00:00
shell.h Remove clause 3 from the UCB licenses. 2004-04-06 20:06:54 +00:00
show.c Remove extra getenv() declaration. 2005-09-02 22:28:27 +00:00
show.h Remove clause 3 from the UCB licenses. 2004-04-06 20:06:54 +00:00
TOUR
trap.c Various small code cleanups resulting from a code reviewing 2005-09-06 19:30:00 +00:00
trap.h Remove clause 3 from the UCB licenses. 2004-04-06 20:06:54 +00:00
var.c Use prototypes in the MKINIT lines collected by mkinit. 2005-08-13 08:12:18 +00:00
var.h Remove clause 3 from the UCB licenses. 2004-04-06 20:06:54 +00:00