Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 717396 - net-wireless/unifi - improvements to mongod wrapper script
Summary: net-wireless/unifi - improvements to mongod wrapper script
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal enhancement (vote)
Assignee: Ben Kohler
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-04-14 09:07 UTC by Jaco Kroon
Modified: 2020-04-14 17:55 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
mongod replacement wrapper script (mongod,305 bytes, text/plain)
2020-04-14 09:16 UTC, Jaco Kroon
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jaco Kroon 2020-04-14 09:07:21 UTC
The wrapper mongodb script could use exec in the last step to eliminate one additional floating process.  The wrapper also doesn't deal with spaces in any arguments (which currently isn't an issue, but one never know in the future), as such, I'm proposing replacement with the attached.

The proposed change does not affect functionality in any way, it merely gets the shell process out of the system.

Reproducible: Always
Comment 1 Jaco Kroon 2020-04-14 09:16:33 UTC
Created attachment 632748 [details]
mongod replacement wrapper script
Comment 2 Ben Kohler gentoo-dev 2020-04-14 11:35:49 UTC
I'll be honest, I don't understand the logic in the for loop, and I don't understand how spaces could be a problem for the sed I'm doing now.

Adding exec seems like a good idea though.
Comment 3 Jaco Kroon 2020-04-14 12:38:05 UTC
It loops through the arguments one by one, shifting it out, and then appending it onto the arguments again once it's decided it must stay.

for arg in "$@"; do

would have been more complete.

Let's say:

$1="/some path/with spaces"
$2="--removearg"
$3="--removearg-but-not-quite"

Your logic would end up with:

$1="/some"
$2="path/with"
$3="spaces"
$4="-but-not-quite"

Mine would end up with:

$1="/some path/with spaces"
$2="--removearg-but-not-quite"

If you really only want to take the exec that's also fine by me.  The space scenario as well as the matching argument within another is unlikely enough that I won't push the issue.
Comment 4 Ben Kohler gentoo-dev 2020-04-14 17:40:45 UTC
Thanks for the explanation, it (mostly) makes sense and the few tests I tried to behave as we want.
Comment 5 Larry the Git Cow gentoo-dev 2020-04-14 17:55:36 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=dec01d375dab043eaf11cf012958e9843745705f

commit dec01d375dab043eaf11cf012958e9843745705f
Author:     Ben Kohler <bkohler@gentoo.org>
AuthorDate: 2020-04-14 17:48:09 +0000
Commit:     Ben Kohler <bkohler@gentoo.org>
CommitDate: 2020-04-14 17:54:27 +0000

    net-wireless/unifi: mongod-wrapper improvements
    
    Thanks to Jaco Kroon
    
    Closes: https://bugs.gentoo.org/717396
    Package-Manager: Portage-2.3.99, Repoman-2.3.22
    Signed-off-by: Ben Kohler <bkohler@gentoo.org>

 net-wireless/unifi/files/mongod-wrapper | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)