Questions tagged [shell]
The shell is Unix's command-line interface. You can type commands in a shell interactively, or write scripts to automate tasks. Use this tag for questions applying to /bin/sh and most compatible shells (ash, bash, ksh, zsh, …). For shell scripts with errors, please check them in http://shellcheck.net before posting here.
12,290 questions
0
votes
0
answers
46
views
the shell escape security issue with the container
I have develop a latex render engine that run with kubernetes container pod, now I want to supprot the minted package that need to open the shell escape feature.
use std::process::Command;
use std::...
1
vote
1
answer
40
views
Cancel just second command of bash logical AND operator [duplicate]
It often happens that I have some long task running, like compiling a program, running tests or copying large archives. Once I am done with whatever else I was doing, I want to leave the computer ...
5
votes
2
answers
866
views
POSIX sh alternative to using [[ ... ]] in Bash
I am using this code to parse the first argument passed to my script. It error handles and it works just the way I want it:
if [ -z "$action" ]; then
printf "[${c_RED}ERROR${c_RESET}...
3
votes
1
answer
108
views
Wine cmd automatically escapes quotes, adds backslash
$ wine cmd /c 'echo "hello world"'
\"hello world\"
Where do the backslashes come from?
The command behaves differently in an interactive session:
$ wine cmd
Microsoft Windows 6.1....
4
votes
1
answer
217
views
Choice of field separator affects sort's ordering
Suppose we have a script named test_sort in our $PATH with the following contents:
#!/bin/bash
function echo_text () {
printf -- "%s\n" "$fc$oc$fs$lc"
printf -- "%s\n&...
1
vote
2
answers
84
views
Sorting output from find more like tree --dirsfirst -F
Here is a sample directory tree as it would appear if it were sorted in character code order (i.e., directories are not listed first):
${PREFIX}/
.bashrc
.include.sh.d/
common.sh
...
14
votes
2
answers
1k
views
Why do shell control statement have that syntax (semicolon/newline+then/do)
I of course realize the need to have something that separates the condition to the actual commands to be executed under the control statement, but why were it chosen to use both semicolon and a ...
0
votes
1
answer
75
views
LF file manager : how to go back to $OLDPWD?
What do I want :
On the file manager lf, we can bind some keyboard shortcuts to do either a lf command with :, or a shell command with $, !, or other symbols.
According to the documentation, there is ...
5
votes
2
answers
274
views
Why are there so many shell scripts using "x$var" = "xabc" instead of "$var" = "abc"? [duplicate]
In the old times of DOS batch scripts, the only way to check for a variable to be empty or to allow an empty variable was to prepend (or append) a known letter, commonly the letter x, because there ...
0
votes
0
answers
57
views
pgrep executable matching specific (current) user only
In a code review on Final look at my Lightshot print screen Linux handler POSIX shell script, specifically in this short answer, it has been pointed out to me, that if there are multiple X servers ...
0
votes
0
answers
45
views
User can't execute a shell script based on shebang but ok when interpreter directly invoked [duplicate]
Context
I have a system user caddy and a shell script placed under /run/caddy/caddy-cert-obtained-wrapper.sh.
/run and /run/caddy are owned by root:root with permissions 0755.
caddy-cert-obtained-...
-1
votes
2
answers
105
views
Unix folder has file named "-f". Standard `/bin/bash` tools do not recognized this (can not `rm`, `cat`, nor `stat` this). What to do? [duplicate]
Welcome to Termux
Docs: https://doc.termux.com
Community: https://community.termux.com
Working with packages:
- Search: pkg search <query>
- Install: pkg install <package>
- ...
2
votes
1
answer
625
views
What is the purpose of using && at the end of a sh script line?
I have seen code like this in a /bin/sh script:
repo_files=$(git ls-files) &&
There is no line continuation. What is the purpose of && at the end of a line like this? Can the '...
-4
votes
1
answer
229
views
How to redirect command output to a file if the command itself contains redirection
In the below shell script I'm executing the some command cmd remotely where in the command output is redirected to some file cmd_log. I'm getting the desired result as long as the command cmd itself ...
10
votes
4
answers
965
views
With `#!/bin/sh`, what is the closest to `;;&` (`bash`'s fallthrough)?
Without ;;&, /bin/sh gives Syntax error: ")" unexpected (expecting ";;").
;;& triggers shellcheck's ^-- SC2127 (error): To use cases with ;;&, specify #!/usr/bin/env ...