[PATCH v2 modular 1/1] build.sh: use the script name only, not the path in usage statement

Dan Nicholson dbn.lists at gmail.com
Tue Dec 14 18:40:16 PST 2010


On Tue, Dec 14, 2010 at 4:35 PM, Gaetan Nadon <memsize at videotron.ca> wrote:
> On Tue, 2010-12-14 at 15:08 -0800, Dan Nicholson wrote:
>
> On Tue, Dec 14, 2010 at 7:38 AM, Gaetan Nadon <memsize at videotron.ca> wrote:
>> If invoked from $PREFIX you currently you get:
>> Usage: util/modular/build.sh [options] prefix
>>
>> Where you should always get:
>> Usage: build.sh [options] prefix
>>
>> The path name is not part of the usage. The GNU compiler and
>> associated tools do not use the path.
>>
>> Autoconf recommends using "expr" rather than "basename" for portability.
>>
>> Signed-off-by: Gaetan Nadon <memsize at videotron.ca>
>> ---
>>  build.sh |    5 +++--
>>  1 files changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/build.sh b/build.sh
>> index d6c946e..027c1c0 100755
>> --- a/build.sh
>> +++ b/build.sh
>> @@ -934,7 +934,8 @@ process_module_file() {
>>  }
>>
>>  usage() {
>> -    echo "Usage: $0 [options] prefix"
>> +    basename="`expr "//$0" : '.*/\([^/]*\)'`"
>> +    echo "Usage: $basename [options] prefix"
>>     echo "  where options are:"
>>     echo "  -a : do NOT run auto config tools (autogen.sh, configure)"
>>     echo "  -b : use .build.$HAVE_ARCH build directory"
>> @@ -953,7 +954,7 @@ usage() {
>>     echo "  --cmd cmd : execute arbitrary git, gmake, or make command
>> 'cmd'"
>>     echo "  --modfile file : only process the module/components specified
>> in 'file'"
>>     echo ""
>> -    echo "Usage: $0 -L"
>> +    echo "Usage: $basename -L"
>>     echo "  -L : just list modules to build"
>>     echo ""
>>     envoptions
>
> Since build.sh is a POSIX shell script, might I suggest parameter
> expansion with ${0##*/}?
>
> Thanks for the suggestion.
>
> My Bash book says that "pattern-matching variable operators"
> do not work on the Bourne shell and we have build.sh users running with this
> shell.
>
> Trevor had to remove getopt() and local variables. Would we face similar
> issues
> with this operator?

Oh, never mind. I thought you guys had decided on POSIX shell as a baseline.

--
Dan


More information about the xorg-devel mailing list