Questions tagged [eval]
The eval tag has no summary.
81 questions
5
votes
2
answers
420
views
How to do indirect variable substitution in a GNU Makefile?
In the shell I can do
$ a=b b=c; eval echo \$$a
c
How do I do the same with GNU Make's $(eval) function?
$ cat Makefile
a=b
b=c
x:; echo {What goes here in order to get:}
$ make
c
0
votes
1
answer
101
views
In Bash 5.2+, is there a means to read the command currently being evaluated?
...that is to say, is there a means by which I can read the full command that's being evaluated AS it's happening? Here's a contrived example, but one I feel makes the question clear:
function ...
0
votes
1
answer
147
views
How to properly make eval safe?
I'm writing a shell script that changes its behavior based on the number of positional parameters passed
script.sh
if [ $# -eq 1 ]; then
if [ -f "$1" ]; then
validate='validate <&...
0
votes
1
answer
101
views
eval for pathnames from mkdir -p
I am writing a script to move around a bit of data, which I want to be able to create the parent directory to where I am sending my data, in order to do some renaming/cleaning of filenames I need to ...
1
vote
0
answers
19
views
While Loop Exits After Calling Function [duplicate]
I'm trying to do a db backup script using Bash.
When adding a "Resume" feature to the script, I do the following loop calling defined functions to do step by step (depending on the .lock ...
0
votes
2
answers
151
views
Confusing results of eval + sed combination [closed]
I run a game from steam which starts with the game companies launcher app where I have to click another button to start the actual game.
The game launcher is very slow, contains needless advertising, ...
0
votes
2
answers
647
views
eval: $? vs ${PIPESTATUS[@]} (bash)
In bash 5.0, I wish to capture the ${PIPESTATUS[@]} of a piped command that is executed via eval. However, eval appears to mask ${PIPESTATUS[@]}, but doesn't mask $? which is the equivalent to ${...
0
votes
1
answer
1k
views
Sanitize input that is used to update script
Looking at a bash-script that takes input from Git commit comment to update itself. Simplified:
script:
#!/bin/bash
comment=''
printf '%s\n' "$comment"
upgrade_script() {
# ...
0
votes
1
answer
86
views
Shell script: Using variables makes command fails ( substituting values of variables manually ; command works fine )
In a bash script:
jenkins_folder=`cut -d "|" -f1 -s input.csv`
jenkins_url='https://url.com:8181/jenkins/view/'
echo "jenkins_folder : ${jenkins_folder}"
for job in ...
4
votes
4
answers
778
views
awk or perl to eval mathematical expressions in each line
I want a script to make awk to become an interactive mathematical calculator, to eval mathematical expressions given in each line.
I.e., instead of constructing awk commands to calculate expressions ...
1
vote
1
answer
1k
views
Command output evaluation not working in Bash script [duplicate]
I am trying to automate adding Homebrew to my path in a shell script, but these two lines do not evaluate inside my shell script:
#!/bin/sh
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)&...
-1
votes
1
answer
113
views
use a variable as a variable
I'd like to use a variable variablenaam for using in a loop.
I tried for hours but can't make it work.
My experiment in bash on a RPi 4 with the latest Raspbian.
I like to make the use of xstack1 and ...
0
votes
1
answer
407
views
Declare variable in eval Bash
There is a way to declare variable in eval ? For example
function test
{
eval $1
}
test "
value="foo"
echo "$value"
"
But it display nothing.
...
0
votes
0
answers
302
views
How does one store the evaluation of a big string with multiple env variables $VAR into another env variable?
Becuase I need to make sure I run authentication for my nohup commands I need the real command I want to run to be in a string in here:
nohup sh -c 'echo $SU_PASSWORD | /afs/cs/software/bin/reauth; ...
0
votes
2
answers
457
views
Bash: how to wrap a command to measure its elapsed time?
How to wrap a command to measure its elapsed time?
Currently I do it using eval:
do_cmd_named()
{
local name=$1
local cmd=$2
echo "$name"
local start_time=$(date +%s)
eval "$...