Skip to main content

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.

10 votes
4 answers
947 views

Without ;;&, /bin/sh gives Syntax error: ")" unexpected (expecting ";;"). ;;& triggers shellcheck's ^-- SC2127 (error): To use cases with ;;&, specify #!/usr/bin/env ...
Swudu Susuwu's user avatar
1 vote
3 answers
367 views

I need to extract information from a log file that is deleted and recreated every time a program runs. After detecting that the file exists (again), I would like to tail it for a certain regexp. The ...
user2066480's user avatar
0 votes
1 answer
156 views

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}" ...
s.k's user avatar
  • 521
2 votes
4 answers
171 views

I want to execute commandA which prints the following: line1 line2 line3 started successfully line4 ... ... And when the line started successfully is printed I want to start another command (and ...
Marinos An's user avatar
5 votes
3 answers
1k views

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() ...
zomega's user avatar
  • 1,022
0 votes
0 answers
29 views

The last elif arm does not get executed: #!/usr/bin/bash searches=("feet" "axilas" "lactant") length=${#searches[@]} searchFunction() { echo "Enter the respective ...
John Smith's user avatar
0 votes
0 answers
15 views

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: ...
andy's user avatar
  • 1
6 votes
1 answer
8k views

I am working on a shell script and decided to check my work via shellcheck.net. I am able to get functionally the same behavior of the following two lines in my script: findmnt /dev/sda1 >/dev/null ...
Kahn's user avatar
  • 1,827
2 votes
1 answer
427 views

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> | ...
variable_expander's user avatar
0 votes
1 answer
45 views

Goal: less the contents (from a variable) and then ask the user whether the contents should be saved to a file (i.e., .recovered_object) only after the user quits out of less. The excerpt from my ...
Per48edjes's user avatar
0 votes
2 answers
361 views

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 ...
Abhishek Jain's user avatar
3 votes
5 answers
3k views

One feature of Perl that I really like is its generalization of looping control keywords to any curly-brace-delimited lexical block1. For example, one can use Perl's last directive to exit any such ...
kjo's user avatar
  • 16.4k
4 votes
2 answers
5k views

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 ...
Stripy42's user avatar
3 votes
2 answers
15k views

$!/bin/sh if grep "$1" /etc/passwd 2>/dev/null #Search username at beging of line1 then echo "Pattern found - Job Over" else echo "Pattern not found" fi
Shridhar B Waghamare's user avatar
7 votes
2 answers
1k views

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. ...
Akshdeep Singh's user avatar

15 30 50 per page
1
2 3 4 5 6