All Questions
12 questions
0
votes
0
answers
155
views
Disable Bash completion for a single environmental variable
Suppose I have an environmental variable $SAVE_DIR=/etc/ used to return to a saved directory (here /etc/) from any Bash shell. Typing cd $SAV[Tab] expands to cd $SAVE_DIR which is quite convenient. ...
2
votes
0
answers
125
views
Why `declare -p VAR` returns "declare -- VAR" on an unset local variable but gives an error "bash: declare: A: not found" on an unset global variable?
I don't understand:
$ declare -i VAR=0; \
> echo "$A"; \
> fun() { local -i VAR=1; echo {; echo "$VAR"; declare -p VAR; unset VAR; echo "$VAR"; declare -p VAR; echo ...
1
vote
1
answer
443
views
Script the create hardlinks, that numbers them based on existing file names and if certain conditions are met?
I should start by saying I'm a coding noob. The script I'm working on is really pushing my limited skills to the limit. Please forgive the length of the post. I have tried to keep it short but I think ...
14
votes
2
answers
5k
views
Why can I not use variables as prefix to a command to set environment variables?
Normally, it is possible to set an environment variable for a command by prefixing it like so:
hello=hi bash -c 'echo $hello'
I also know that we can use a variable to substitute any part of a ...
10
votes
4
answers
11k
views
echo names and values of all env variables that start with "nlu_setting"
I am looking for a way to echo names and values of all env variables that start with nlu_setting, so the output might look like:
nlu_setting_json=true
nlu_setting_global=0
nlu_setting_bar=foo
does ...
5
votes
4
answers
3k
views
Pass arguments for use in a grandchild process
I have a list of arguments and three processes:
bash_script -> child -> grandchild
The list of arguments is aimed at the grandchild. I can modify all three processes. The grandfather script ...
4
votes
1
answer
255
views
Safely define an environment variable
AFAICT, neither GNU Bash, nor any other relevant package (e.g. GNU coreutils) that is commonly available in GNU/Linux distros, has a ready-made way to define an environment variable such that the ...
3
votes
2
answers
7k
views
Can I introspect the type of a bash variable?
I'm writing a function that outputs dates. I'd like to allow the user to customize the output by supplying arguments to date with an environment variable. To preserve white space in format strings, I'...
4
votes
1
answer
5k
views
how to get or reflect the name of the bash function which is called? [duplicate]
i did not yet found a solution to this. Anyone a hint?
i sometimes write bash functions in my shell scripts and i love to have my scripts being verbose, not just for debugging. so sometimes i would ...
15
votes
3
answers
5k
views
Indirectly expand variables in shell
I need to indirectly reference a variable in the bash shell.
I basically want to what you can do in make by writing $($(var)).
I have tried using ${$var} which would be the most straight forward ...
1
vote
2
answers
2k
views
Identify user defined variables
In a GNU/Linux bash shell, I am using a command to identify and save all my user defined variables at a specific point in time for debugging purposes (I source the file later):
declare | grep '^[[:...
2
votes
2
answers
1k
views
How to print shell variables and values to be able to copy/paste them?
In Bash 4.2.25, the set and env output is not escaped, so shell escapes and any non-printable characters won't be copy-pasteable. Take for example this shell session:
$ export foo=$'a\nbar=\baz'
$ ...