Project

General

Profile

Bug #9020

/bin/sh has problem with empty arguments

Added by Bruno Haible over 2 years ago. Updated over 2 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
-
Start date:
2018-02-03
Due date:
% Done:

0%

Estimated time:
Difficulty:
Medium
Tags:
needs-triage
Gerrit CR:

Description

The /bin/sh shell, unlike /usr/bin/bash, apparently ignored empty arguments within "$" or ${1+:$"}.

How to reproduce:
1. wget https://ftp.gnu.org/gnu/libunistring/libunistring-0.9.8.tar.gz
2. tar xfz libunistring-0.9.8.tar.gz
3. cd libunistring-0.9.8.tar.gz
4. ./configure; make; make check
=> The test test-locale-language.sh crashed. It invokes test-locale-language.c. This is a program that crashes when invoked with 0 arguments and succeeds when invoked with an empty argument. The script passes an empty argument.
However, test-locale-language here is a libtool-generated shell script that is meant to forward its arguments to the actual executable.
5. cd tests
6. LC_ALL=C ./test-locale-language ''
=> crashes
7. Edit test-locale-language, replacing /bin/sh in the first line with /usr/bin/bash.
8. LC_ALL=C ./test-locale-language ''
=> works fine.


Files

args.c (208 Bytes) args.c Bruno Haible, 2018-02-03 12:44 AM
args-via-sh (33 Bytes) args-via-sh Bruno Haible, 2018-02-03 12:44 AM
args-via-bash (39 Bytes) args-via-bash Bruno Haible, 2018-02-03 12:44 AM

History

#1

Updated by Bruno Haible over 2 years ago

A simpler test case is as follows:
1. gcc -O -Wall args.c -o args
2. chmod a+x args-via-sh args-via-bash
3. LC_ALL=C ./args-via-bash abc ''
=>
argc = 3
argv0 = ./args
argv1 = abc
argv2 =
4. LC_ALL=C ./args-via-sh abc ''
=>
argc = 2
argv0 = ./args
argv1 = abc

#2

Updated by Alexander Pyhalov over 2 years ago

  • Project changed from OpenIndiana Distribution to illumos gate

Also available in: Atom PDF