MantisBT - Doomseeker
View Issue Details
0003172Doomseeker[All Projects] Bugpublic2017-06-27 00:482018-10-27 22:55
Konda 
Blzut3 
normalmajoralways
closedfixed 
LinuxUbuntu10.04 x86-64
1.1 
1.21.2 
0003172: Zandronum shell scripts for running test builds cause no PWADs to be loaded if the path contains spaces
One of the main file paths I give to Doomseeker is '/windows/Program Files (x86)/Zandronum/PWADs/'. When joining a server hosting Zandronum 3.0 alpha, after Doomseeker downloads the build, I fail to join the server because Zandronum has loaded 0 PWADs:'http://i.imgur.com/7lEPko8.png [^]'
When I use a different path for PWADs, like '/home/konda/Links/Zandronum/PWADs', Zandronum has files loaded normally and I can join the server that runs the beta version of Zandronum. The second path I mentioned is actually a symbolic link to the first path, which proves that the cause of the problem is within the way Doomseeker calls for the zandronum executable and is related to whether the file path contains spaces.
1. Set up your file paths in Doomseeker so the first one that leads to your pwads directory contains spaces in its path
2. Join a Zandronum server that runs a beta build you don't have and let Doomseeker set everything up
When searching for the cause of the problem, I noticed that Doomseeker's "Join command line" actually calls a shell script instead of the Zandronum test build executable directly.
This is what the shell script looked like which Doomseeker was calling from the command line in my case:'https://pastebin.com/atw34Ff0 [^]'
The problem is the way the shell script passes the arguments to Zandronum. The $* shell expansion splits all command line arguments which contain spaces. The proper shell argument expansion which preserves the arguments exactly as they were passed to the script is "$@" (with the quotes). When I replace $* with "$@" everything works fine.

'https://www.gnu.org/software/bash/manual/html_node/Special-Parameters.html#Special-Parameters [^]'
Here it clearly states that word splitting is performed on all arguments expanded with $*, and in the case of $@: 'When the expansion occurs within double quotes, each parameter expands to a separate word. That is, "$@" is equivalent to "$1" "$2" ….'
No tags attached.
Issue History
2017-06-27 00:48KondaNew Issue
2017-06-27 00:54KondaNote Added: 0017942
2017-06-27 00:56KondaNote Edited: 0017942bug_revision_view_page.php?bugnote_id=17942#r10741
2017-07-02 08:41ZalewaAssigned To => Zalewa
2017-07-02 08:41ZalewaStatusnew => assigned
2017-07-02 09:28ZalewaNote Added: 0017963
2017-07-02 09:28ZalewaAssigned ToZalewa => Blzut3
2017-10-30 04:36WubTheCaptainStatusassigned => needs testing
2017-10-30 04:37WubTheCaptainStatusneeds testing => needs review
2017-10-30 04:41WubTheCaptainNote Added: 0018679
2017-11-03 04:30Blzut3Note Added: 0018736
2017-11-03 04:30Blzut3Statusneeds review => needs testing
2017-11-03 04:31Blzut3Fixed in Version => 1.2
2017-11-03 04:31Blzut3Target Version => 1.2
2018-09-27 02:48WubTheCaptainNote Added: 0019785
2018-09-27 02:48WubTheCaptainStatusneeds testing => resolved
2018-09-27 02:48WubTheCaptainResolutionopen => fixed
2018-10-27 22:55WubTheCaptainStatusresolved => closed

Notes
(0017942)
Konda   
2017-06-27 00:54   
(edited on: 2017-06-27 00:56)
Edit: I forgot to add that this same behavior was present in Doomseeker 1.0, from the few times I've joined a Zandronum beta server.

Additionally, you can see that /usr/bin/zandronum, which is a shell script (as installed by the zandronum package from drdteam's debian package repository), also uses the "$@" expansion and so far I've never had a single problem with passing command-line arguments to this script:
konda@mint ~ $ cat /usr/bin/zandronum
#!/bin/bash

exec /usr/games/zandronum/zandronum "$@"

(0017963)
Zalewa   
2017-07-02 09:28   
Fixed on Linux:'https://bitbucket.org/Doomseeker/doomseeker/commits/5ac4962080d59afb4a241765eca0df57f7c32465 [^]'

I suspect Mac OS X suffers the same issue, but I didn't touch that because I cannot check.
(0018679)
WubTheCaptain   
2017-10-30 04:41   
A little bit of off-topic chatter: I remember manually long ago in 1.1 fixing these by hand, but also other ShellCheck errors/warnings. Now that Zandronum 3.0 is out, I can't unfortunately remember what all the ShellCheck errors/warnings were about. This was one of them.
(0018736)
Blzut3   
2017-11-03 04:30   
Applied same fix to OS X.
(0019785)
WubTheCaptain   
2018-09-27 02:48   
"$@" with quotes is the only valid option here without ShellCheck warnings, so I believe this is resolved.

Note I didn't actually test this (setting up a Zandronum testing server takes more time than I desire to spend), but I have high confidence this patch is correct (although the code line looks a bit confusing with escaping double quotes).

"$@" is POSIX sh compliant.