feature_to_c.sh: Print help when passing no arguments

Message ID 1456770606-2944-1-git-send-email-simon.marchi@ericsson.com
State New, archived
Headers

Commit Message

Simon Marchi Feb. 29, 2016, 6:30 p.m. UTC
  I found that odd that passing no arguments to feature_to_c.sh produces
this:

$ ./feature_to_c.sh
./feature_to_c.sh: 23: shift: can't shift that many

but passing one argument shows the help:

$ ./feature_to_c.sh hello
Usage: ./feature_to_c.sh OUTPUTFILE INPUTFILE...

This patch changes the script to show the help in both cases.

gdb/ChangeLog:

	* features/feature_to_c.sh: Print the help when passing no
	argument.
---
 gdb/features/feature_to_c.sh | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
  

Comments

Yao Qi March 4, 2016, 11:35 a.m. UTC | #1
Simon Marchi <simon.marchi@ericsson.com> writes:

> gdb/ChangeLog:
>
> 	* features/feature_to_c.sh: Print the help when passing no
> 	argument.

Looks good to me.
  
Simon Marchi March 4, 2016, 3:05 p.m. UTC | #2
On 16-03-04 06:35 AM, Yao Qi wrote:
> Simon Marchi <simon.marchi@ericsson.com> writes:
> 
>> gdb/ChangeLog:
>>
>> 	* features/feature_to_c.sh: Print the help when passing no
>> 	argument.
> 
> Looks good to me.
> 

Pushed, thanks!
  

Patch

diff --git a/gdb/features/feature_to_c.sh b/gdb/features/feature_to_c.sh
index 901eb0d..439611a 100755
--- a/gdb/features/feature_to_c.sh
+++ b/gdb/features/feature_to_c.sh
@@ -19,14 +19,14 @@ 
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-output=$1
-shift
-
-if test -z "$output" || test -z "$1"; then
+if test -z "$1" || test -z "$2"; then
   echo "Usage: $0 OUTPUTFILE INPUTFILE..."
   exit 1
 fi
 
+output=$1
+shift
+
 if test -e "$output"; then
   echo "Output file \"$output\" already exists; refusing to overwrite."
   exit 1