Changeset f6d5ca1 in wspkg for wspkg-sh/packages-cpp.sh


Ignore:
Timestamp:
Feb 28, 2019, 8:42:37 PM (3 years ago)
Author:
Ting-Wei Lan <lantw44@…>
Branches:
master
Children:
a2c0986
Parents:
2e6149f
git-author:
Ting-Wei Lan <lantw44@…> (02/28/19 20:27:39)
git-committer:
Ting-Wei Lan <lantw44@…> (02/28/19 20:42:37)
Message:

Use 'printf' to print non-constant strings in shell scripts

It is unsafe to use 'echo' with strings with variable substitutions.
Different 'echo' implementations may accept different options, and they
can interpret strings with escape characters in different ways. The
behavior of 'printf' is much more consistent so it should be preferred.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wspkg-sh/packages-cpp.sh

    r2e6149f rf6d5ca1  
    22
    33toupper () {
    4     echo "$1" | sed 's/^-//' | tr '[:lower:]' '[:upper:]'
     4    printf '%s\n' "$1" | sed 's/^-//' | tr '[:lower:]' '[:upper:]'
    55}
    66
    7 [ -z "$1" ] && echo "Usage: $0 input_file cpp_args" && exit 1
     7[ -z "$1" ] && printf 'Usage: %s input_file cpp_args\n' "$0" && exit 1
    88[ -z "$2" ] && default="yes"
    99
Note: See TracChangeset for help on using the changeset viewer.