Questions tagged [control-flow]
Control flow refers to the order that computer code is executed in when a program or script is running. Examples include loops (code is repeated) and conditionals where one branch is run instead of another. Use this tag for questions about control flow in scripts or programs – not questions about terminal flow control.
83 questions
10 votes
4 answers
943 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 ...
0 votes
1 answer
156 views
Is a newline equivalent to && in a bash script?
I'm very simply wondering if, in a bash script, a new line is functionally 100% equivalent to &&? e.g.: #!/bin/bash 7z x "${file}" mv "${file}" "${new_file}" ...
5 votes
3 answers
985 views
Tool to detect errors in application's execution logic
I want to detect errors in application's execution logic. E.g.: forgot to call free() on address returned by malloc() did not close file handle returned by open() invalid flags passed to open() ...
0 votes
0 answers
15 views
my if statement is returning command not found [duplicate]
in my script an if statement returns: line 3: []: command not found the statement: if ["$(pidof -x $(basename $0) -o %PPID)"]; then echo process already running; exit; fi what I tried: ...
2 votes
1 answer
427 views
Executing a remote script from a code repository causes endless loop
I often execute raw versions of remote Bash scripts in GitHub with this pattern: wget -O - https://raw.githubusercontent.com/<username>/<project>/<branch>/<path>/<file> | ...
0 votes
2 answers
343 views
How to modify and write to file before printing to STDERR
I am working on an automated pull request check via GitHub actions and I want to preserve some data from a command's stderr output between jobs. For this, I need to write the stderr to an artifact ...
4 votes
2 answers
5k views
Return "continue" from function called from loop
I'm currently refactoring a script which has slowly grown beyond control. I'm trying to spin off repetition into functions. However, I have a repeated test being called from a loop, and want it to ...
7 votes
2 answers
1k views
How to know the code flow of a driver module?
I am studying Linux device drivers, my main focus is on wifi drivers. I want to know how the code flows when I plugin my device. Maybe, I can do something like add a printk line in every function. ...