Help understanding evaluation order


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help understanding evaluation order
# 1  
Old 04-18-2017
Help understanding evaluation order

I have made a simple script to find all programs that use a tcp wrapper, it will supply a reasonable default for my system if none is given.

After some digging I realized that the expansion operators pass their default return value single quoted (according to bash -x trace). I have wildcard expansions in my return value, and it works if used with eval.

Its working perfect with eval, but I don't know why.

Code:
#! /bin/bash

ldd_path="$*"

while read line
do
     if [[ "$line" =~ ^/.*:$ ]]
     then
          current_binary="$line"
     elif [[ "$line" =~ .*libwrap.so.0.* ]]
     then
          printf '%s\n' "$current_binary"
     fi
done < <(eval ldd ${ldd_path:-"/usr/bin/* /usr/sbin/*"})

My question is really how is eval working with wildcards if they are passed with single quotes, bash -x shows eval working on this:

Code:
eval ldd '/usr/bin/* /usr/sbin/*'

I though evaluation order will prevent this from working but it is.

Can somebody elaborate on this for me Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Evaluation of test command

Could somebody please explain to me why and how the highlighted line(s) (?) of code puts the "test" evaluation into "result" and then to $enable_static ? Or does not ? I did comment out the original code and changed it to what I feel is less cryptic , but the "result" is still wrong =... (3 Replies)
Discussion started by: anne
3 Replies

2. Shell Programming and Scripting

Help understanding evaluation order

I have made a simple script to find all programs that use a tcp wrapper, it will supply a reasonable default for my system if none is given. After some digging I realized that the expansion operators pass their default return value single quoted (according to bash -x trace). I have wildcard... (2 Replies)
Discussion started by: phuongnguyen
2 Replies

3. AIX

Older versions of the XL C/C++ Evaluation for AIX 5.3

Hello, IBM offers a evaluation version of their XL C/C++ compiler. Unfortunatly v16.1 (from Developerworks) can not be installed on AIX 5.3 (I can not upgrade my old 32 Bit RS/6000 to a later version) and I have not found any older versions on the IBM and Developerworks pages. Is there a... (8 Replies)
Discussion started by: eh2scqw
8 Replies

4. Shell Programming and Scripting

Bash regex evaluation not workin

I'm building a script that may received start and end date as parameters. I whant to make it as flexible as possible so I'm accepting epoch and date in a way that "date --date=" command may accept. In order to know if parameter provided is an epoc or a "date --date=" string I evaluate if the value... (2 Replies)
Discussion started by: lramirev
2 Replies

5. Cybersecurity

iptables latency evaluation

Hello guys, I'm actually working on my master thesis which has for subject the evaluation of virtual firewall in a cloud environment. To do so, I installed my own cloud using OpenNebula (as a frontend) and Xen (as a Node) on two different machines. The Xen machine is my virtual firewall thanks... (2 Replies)
Discussion started by: Slaughterman
2 Replies

6. UNIX for Dummies Questions & Answers

cp command evaluation

Hi all! I'm writting one script to copy a file in various folders, but there are 2 things to validate. First that the folder where i'll be cpying exists, and second that i have permissions to copy the file in it. so far i have found the way to validate the folder exists, but when trying to... (6 Replies)
Discussion started by: feliperivera
6 Replies

7. UNIX for Dummies Questions & Answers

Evaluation syntax in Unix commands

I know this should be simple, but sorry I am fairly new to UNIX and can't find the syntax to make this work. I have the following two commands in a script: x=`expr $(head -1 filename.ext | cut -c16 | grep | wc -l) + 16` del=`head -1 filename.ext | cut -c$x` This works fine as I expect... (2 Replies)
Discussion started by: DJR
2 Replies

8. Shell Programming and Scripting

Using AWK in IF evaluation in KSH

Hi - I have an expression that evaluates to "Alive" or some other condition. e.g. if I run :- awk -F \| '{gsub(/]*/,"",$4); print $4 }' then the output is "Alive". I want to be able to test this as the result may be some other condition other than "Alive". I have tried the following... (4 Replies)
Discussion started by: sniper57
4 Replies

9. Shell Programming and Scripting

AWK equation evaluation.

Hi, Is there a way to evaluate an equation contained in a string within an AWK script? For example: A = "(5*2)-1" (this equation is read from a file and varies line by line) In this example, I can't see any way to get an answer of 9 unless I do: cmd = "awk 'BEGIN{print "A"}'" cmd |... (3 Replies)
Discussion started by: srdgeo
3 Replies
Login or Register to Ask a Question