Bug 41926 - Check for unquoted "dash" local variables
Check for unquoted "dash" local variables
Status: CLOSED FIXED
Product: UCS
Classification: Unclassified
Component: ucslint
UCS 4.1
Other Linux
: P5 normal (vote)
: UCS 4.2
Assigned To: Philipp Hahn
Florian Best
: interim-1
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2016-08-08 11:52 CEST by Philipp Hahn
Modified: 2017-04-04 18:28 CEST (History)
3 users (show)

See Also:
What kind of report is it?: Development Internal
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional):
Max CVSS v3 score:


Attachments
Unquotet use of local in UCS-4.1-3 (16.73 KB, text/plain)
2016-08-08 11:52 CEST, Philipp Hahn
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Philipp Hahn univentionstaff 2016-08-08 11:52:54 CEST
Created attachment 7858 [details]
Unquotet use of local in UCS-4.1-3

"dash" in contrast to "bash" needs quoting for local function variables; otherwise the value is slit on IFS:

> $ dash -c 'f () { local var=$1; }; f "a-b.c-d a-b"'
> dash: 1: local: a-b: bad variable name
> $ dash -c 'f () { local var="$1"; }; f "a-b.c-d > a-b"'

This caused Bug #41917.

ucslint should check shell files for
  git grep -n "\<local\> \w\+=\([^\"'0-9 \$(]\|\$[^'?\$!#({]\|\${[^?\$!#]\)"

This is not perfect as "local" can be used to assign multiple local variables at once.

 $ dash -c 'f () { local var=`echo a-b.c-d a-b`; }; f "a-b.c-d > a-b"'
 dash: 1: local: a-b: bad variable name
 $ dash -c 'f () { local var="`echo a-b.c-d a-b`"; }; f "a-b.c-d > a-b"'
Comment 1 Philipp Hahn univentionstaff 2016-08-30 13:49:24 CEST
r72024 | Bug #41926 ucslint: Check for unquoted local variables

Package: ucslint
Version: 6.0.0-1A~4.2.0.201608301342
Branch: ucs_4.2-0

r72027 | Bug #32539,Bug #41926,Bug #37203: ucslint
 ucs-4.2-0/doc/changelog/changelog-4.2-0.xml
Comment 2 Florian Best univentionstaff 2016-12-22 14:36:57 CET
OK: I changed e.g. bash to sh in:
W:0013-4: univention-backup2master:43: unquoted local variable: local message=$1
OK: changelog
Comment 3 Stefan Gohmann univentionstaff 2017-04-04 18:28:57 CEST
UCS 4.2 has been released:
 https://docs.software-univention.de/release-notes-4.2-0-en.html
 https://docs.software-univention.de/release-notes-4.2-0-de.html

If this error occurs again, please use "Clone This Bug".