FS#60745 - [mame] Invalid shell syntax in launcher script

Attached to Project: Community Packages
Opened by Score_Under (Score_Under) - Thursday, 08 November 2018, 11:33 GMT
Last edited by Antonio Rojas (arojas) - Sunday, 11 November 2018, 10:56 GMT
Task Type Bug Report
Category Packages
Status Closed
Assigned To Antonio Rojas (arojas)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Description:

The mame launcher script contains invalid shell syntax on line 4:

home=('$HOME')

The parentheses are a syntax error in sh, and only work under bash, which is not the interpreter specified in the shebang of the script.
There is also a brace expansion later in the script, which is also bash-only syntax:

mkdir $HOME/.mame/{artwork,cfg,comments,ctrlr,diff,ini,inp,nvram,samples,snap,sta,roms}

(N.B. $HOME should either be in double-quotes here, or replaced with a tilde, otherwise it is subject to undesirable forms of parameter expansion)

Attached is a rewrite of the launcher script compatible with sh, with some behavioural changes (e.g. it now launches on first run after generating the ini file). Many of the changes go out of the scope of this bug report, but I hope the smaller changes like "exec" and checking for "cd" success will also be considered.

Additional info:
* mame 0.203-1
* symlinking /bin/sh to a non-bash shell is a common practice, especially for the dash shell (and this is done by default under Debian and Ubuntu, so there is widespread precedent for people wanting to do this)

Steps to reproduce:
1. run "mame" under a POSIX-compliant non-BASH shell (dash, busybox sh, etc.)
2. observe error: '/bin/mame: 4: /bin/mame: Syntax error: "(" unexpected'
   mame (1.4 KiB)
This task depends upon

Closed by  Antonio Rojas (arojas)
Sunday, 11 November 2018, 10:56 GMT
Reason for closing:  Fixed
Additional comments about closing:  mame 0.203-2

Loading...