All Questions
Tagged with bash-function or bash
156,880 questions
Best practices
0
votes
0
replies
33
views
When packaging a bash binary produced by Bazel, do I need to keep the rlocation/data location boilerplate?
I was trying to exercise with Bazel by packaging a deb package from a collection of scripts I'm writing to automate a few tasks at work. Right now, I keep them either in /usr/local/bin or \~/.local/...
1
vote
0
answers
65
views
Prevent TMUX exit on PTY OOM kill?
I have a high memory program (ML) that I want to run in a tmux session. However, if the process is OOM killed, the tmux session is also shut down. I partially solved it (using the below run-bg), but ...
-2
votes
0
answers
39
views
Error trying to get access token for system-assigned managed identity at particular instance else working fine
Encountering an issue where the access token is not generated at the intended instance when using a Linux VM with system-assigned managed identity to retrieve secrets from Azure Key Vault. This issue ...
4
votes
4
answers
108
views
Map unknown associative array element
How can I map an unknown value alongside other known values in bash using an associative array, so that:
#!/bin/bash
array=("foo" "foo" "bar" "something else" &...
0
votes
2
answers
34
views
Git Bash can't recognize flutterfire command on Windows OS
I have installed Firebase CLI on my Windows OS machine,
I have activated FlutterFire CLI, and have added Dart’s global bin to my system PATH
But when I run flutterfire --version command in my bash ...
1
vote
1
answer
77
views
How can I capture the output of a subprocess (deno) called from a bash script when run by CRON?
I have a bash script that turns off stdout and stderr when not run interactively (i.e. run from CRON).
if [[ ! -t 0 && ! -t 1 ]]; then
#echo "The script is not called ...
1
vote
1
answer
72
views
YQ: load a text file as array and use it for an operation
I have a yaml file with an arbitrary amount of documents, and I'm trying to replace all missing namespaces for namespaceable resources with an arbitrary input one.
Getting the non-namespaceable ...
2
votes
2
answers
117
views
How do I operate on continuous piped output from a bash command?
I'm trying to write a small bash script that will take values from my mouse's horizontal scroll wheel to change my system's volume.
Using this guide, I've come up with the following command to ...
1
vote
1
answer
79
views
Weird prompt rendering with custom $PS1
The question closely follows this one, except that I did what the git-prompt.sh does myself.
However, I started noticing weird rendering issues, where long lines do not wrap on the next console line, ...
1
vote
0
answers
71
views
UI tests blocked by “bash requesting screen access” popup in Mac OS
On macOS, I get a system popup when running UI tests in GitHub saying:
“bash” is requesting to bypass the system private window picker and directly access your screen and audio.
How can I disable ...
0
votes
3
answers
77
views
How can I display the colors of text inserted with color codes by another program in Bash?
When the text directly contained color code for example:
a="\033[0;31mRED\033[0m"
echo -e $a
The terminal had no problem colorizing the text in red. But when I modified the color code ...
0
votes
0
answers
76
views
Running bash script with Lua and Tup causes file permission issues
I am running a legacy C++ build env with Tup, Lua5.4 on Debian13. When I run tup, under any user (also root) there are strange file permission issues. When I debug and do and "ls -l" the ...
-1
votes
0
answers
21
views
.desktop file won’t launch Proton app on double-click (works in terminal) [migrated]
I’m creating a custom Proton-based “Windows layer” (without Steam) to run .exe files directly on Linux.
Running them from terminal works fine — but double-clicking via a .desktop launcher does nothing....
3
votes
1
answer
111
views
bash script concat() in prepared statement for mysql
This gives a syntax error:
read -p "entry: " entry
sql="select concat('entry ', id) from mytbl where id = ?";
$mysql_conn "prepare stmnt from '${sql}'; set @id='${entry}';
...
0
votes
1
answer
100
views
Script to start the Rails server does not work when I use crontab
My script to start the Rails server does not work when I use crontab. I have a script to monitor whether Puma is running or not, and subsequently start the Rails server in production. When I execute ...
3
votes
5
answers
195
views
Using a function to format any list of PATHs
I have this alias to format $PATH into one line per path:
alias path='sed ''s/:/\\n/g'' <<< "$PATH"'
I tried to specify the env var to list, like path $MANPATH but still with a ...
1
vote
0
answers
137
views
Add new element stored in a variable to existing JSON array with jq
I am working on creating an adaptive card dynamically. I have the skeleton on the card in JSON and I want to add entries to it (each entry will be a JSON object inside the "body" of the ...
1
vote
8
answers
252
views
How to check if a file contains *only* a string
I'm trying to interact with an API which returns json and which uses pagination. Unfortunately, they don't give any indication when you're reached the end of the list, they just continue to respond ...
1
vote
2
answers
99
views
How to conditionally add elements to an array in shell script
In the below shell script, I'm trying to conditionally add elements to an array which is syntactically incorrect when checked in shellcheck.
#!/bin/bash
echo "Hello World";
HH=1
ARR=(
&...
0
votes
1
answer
62
views
Syntax error near unexpected token 'elif' in bash concerning conda [closed]
I have a problem with my bash file: each time I launch the terminal, this error occurs:
bash: /home/hk/.bashrc: line 125: syntax error near unexpected token elif' bash: /home/hk/.bashrc: line 125: ...
0
votes
0
answers
60
views
How to escape the backward \ in sed -i to insert to top of file [duplicate]
I have a file that I'm trying to put a spool command and the dos path as the first line:
To get the dos path from bash I use:
CWDDOS=$(pwd | sed 's/\//\\/g' | sed 's/\\c/C:/g')
and it gives me this:
...
0
votes
1
answer
76
views
LaunchAgent refuses to run shell script despite throwing no obvious errors
This question is similar to LaunchAgent doesn't run shell script, but the solutions there didn't work for me as my situation is presumably much more complex.
I have the following Bash script:
#!/...
0
votes
0
answers
81
views
Why bash's export directive doesn't work with eval directive? [duplicate]
I can't figure out why this code outputs VAR= when it should output VAR=val.
Any ideas?
#!/usr/bin/env bash
arr=(
"export VAR=val"
"echo VAR=$VAR"
)
for it in "${arr[...
0
votes
0
answers
85
views
shopt nullglob seems to interfere with associative array? [duplicate]
Associative array appears to behave differently when nullglob is set:
shopt -u nullglob
unset aya
declare -A aya
aya["10"]="hi"
echo ${#aya[@]}
unset aya["10"]
echo ...
0
votes
0
answers
65
views
using bash "read" command twice in a loop [duplicate]
I have a bash script where I use the read command twice:
1st usage: read text file line by line
2nd usage: asking user in the loop to confirm something
However, the second usage is completely ...