Run console commands via a temp script (fixes scripts not executing) - #5
Merged
Conversation
eConsoleAppContainer.execute() is not consistent across images: some run the given string through a shell, some split it on whitespace. The previous approach wrapped remote commands in /bin/sh -c "..." but exempted anything starting with "sh " - so local sh/ scripts reached execute() as 'sh "..." > log 2>&1' with the redirect intact, and on a word-splitting image the redirect tokens became literal arguments and the script silently failed. Remote pipelines were similarly fragile. Instead of guessing how execute() parses the string, write the whole command to a real temp script (/tmp/.lsconsole_<run>.sh) and run '/bin/sh <script>'. A script file is always interpreted by /bin/sh exactly as written, so pipes, redirects, && chains and embedded quotes (the ?inline=false URLs) all work identically on every image. The multi-command path in runFinished now goes through the same helper (it previously executed raw, bypassing any wrapping). Verified by executing all four command shapes (piped remote, embedded quotes, opkg && chain, local sh script with redirect) through the real shell.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
eConsoleAppContainer.execute() is not consistent across images: some run the given string through a shell, some split it on whitespace. The previous approach wrapped remote commands in /bin/sh -c "..." but exempted anything starting with "sh " - so local sh/ scripts reached execute() as 'sh "..." > log 2>&1' with the redirect intact, and on a word-splitting image the redirect tokens became literal arguments and the script silently failed. Remote pipelines were similarly fragile.
Instead of guessing how execute() parses the string, write the whole command to a real temp script (/tmp/.lsconsole_.sh) and run '/bin/sh <script>'. A script file is always interpreted by /bin/sh exactly as written, so pipes, redirects, && chains and embedded quotes (the ?inline=false URLs) all work identically on every image. The multi-command path in runFinished now goes through the same helper (it previously executed raw, bypassing any wrapping).
Verified by executing all four command shapes (piped remote, embedded quotes, opkg && chain, local sh script with redirect) through the real shell.