Community Packages

Please read this before reporting a bug:
https://wiki.archlinux.org/title/Bug_reporting_guidelines

Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.

REPEAT: Do NOT report bugs for outdated packages!
Tasklist

FS#63331 - [plan9port] plan9.sh should quote shell expansion

Attached to Project: Community Packages
Opened by Neven Sajko (Neven) - Wednesday, 31 July 2019, 19:06 GMT
Last edited by Alexander F. Rødseth (xyproto) - Friday, 02 August 2019, 12:59 GMT
Task Type Bug Report
Category Packages
Status Closed
Assigned To Alexander F. Rødseth (xyproto)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 1
Private No

Details

export PATH=$PATH:$PLAN9/bin

should be changed to

export PATH="$PATH:$PLAN9/bin"

The PATH colon separated list can probably have names with spaces in them.
This task depends upon

Closed by  Alexander F. Rødseth (xyproto)
Friday, 02 August 2019, 12:59 GMT
Reason for closing:  Fixed
Comment by Dave Reisner (falconindy) - Wednesday, 31 July 2019, 19:10 GMT
There's no case in which this can break. Word splitting is done prior to parameter expansion, so the assignment is safe without quotes, even when PATH has spaces in it.
Comment by Eli Schwartz (eschwartz) - Friday, 02 August 2019, 02:51 GMT
My bad, it is actually repeatable. In bash, dash, busybox ash, and ksh93, the following works:

export PLAN9=/asdiu
export PATH='a b'
PATH=$PATH:$PLAN9/bin
export PATH

In bash, busybox ash, and ksh93, the following also works, but fails in dash:

export PLAN9=/asdiu
export PATH='a b'
export PATH=$PATH:$PLAN9/bin

This seems like it should be a bug in dash, export var=val should not behave differently from var=val; export var. But according to https://unix.stackexchange.com/questions/193095/where-is-export-var-value-not-available/193137#193137 it is a "known behavior", which sucks.

Comment by Eli Schwartz (eschwartz) - Friday, 02 August 2019, 03:32 GMT
Either quoting the expansion or removing the word "export" should be valid fixes.

Since PATH is already an exported environment variable, you do not need to re-export it every time you modify its value. This is valid in all four shells I tested, and although I don't have the source at hand, I believe (and #bash on Freenode confirmed my belief) that this behavior *is* required by POSIX.
Comment by Kerin Millar (kerframil) - Friday, 02 August 2019, 05:49 GMT
In view of the second comment, see also https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_01. In short, the arguments conveyed to export do not count as "variable assignments" in the context of simple command grammar. Implementations of sh (dash included) are under no obligation to make export a special case just because it happens to be a builtin.
Comment by Alexander F. Rødseth (xyproto) - Friday, 02 August 2019, 12:26 GMT
I'll add double quotes.

Loading...