Evaluation of test command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Evaluation of test command
# 1  
Old 03-29-2019
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 = $enable_static value which is string "no" to start with.







Code:
 # Make sure either enable_shared or enable_static is yes.

  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5
$as_echo_n "checking whether to build static libraries... " >&6; }
echo "@line $LINENO   # Make sure either enable_shared or enable_static is yes."
#  test "$enable_shared" = yes || enable_static=yes  (????) 
test "$enable_shared" = yes || "$enable_static"=yes
  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5
$as_echo "***************  DEBUG  ****** $enable_static" >&6; }

# 2  
Old 03-29-2019
You changed working code into broken code.

|| && are short form if-then-else statements.

Code:
true && echo "This will print"
true || echo "This won't print"
false && echo "This won't print"
false || echo "This will"

# set enable_static to "yes" whenever enable_shared is NOT yes
test "$enable_shared" = yes || enable_static=yes

# 3  
Old 03-29-2019
OK , but the original line of code supposedly evaluate # Make sure either enable_shared or enable_static is yes.and I thought that "||" met "or" . My mistake.





Either way - the code reports " no " which is not correct.
# 4  
Old 03-29-2019
Moderator's Comments:
Mod Comment The person who submitted this thread has been banned...
This thread is closed.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to Force command substitution evaluation in bash?

OK, I'm striving to abide by all the rules this time. Here is a fragment of my windows10/cygwin64/bash script: export BUPLOG=$(BackupRecords --log "$src") robocopy $(BackupRecords -mrbd "$src" --path "$src") $(BackupRecords --appSwitches "$src") "$src" "$dst" $(BackupRecords --fileSwitches... (15 Replies)
Discussion started by: siegfried
15 Replies

2. Shell Programming and Scripting

How to Force command substitution evaluation in bash?

OK, I'm striving to abide by all the rules this time. Here is a fragment of my windows10/cygwin64/bash script: export BUPLOG=$(BackupRecords --log "$src") robocopy $(BackupRecords -mrbd "$src" --path "$src") $(BackupRecords --appSwitches "$src") "$src" "$dst" $(BackupRecords --fileSwitches... (0 Replies)
Discussion started by: siegfried
0 Replies

3. Shell Programming and Scripting

Test file script - if evaluation failing

I have a following script to evaluate if file exist in the directory and then archive it. #!/bin/bash #master directory scriptdir="/flex/sh/interfaces" #change this path only - all other paths are connected with it filedir="/flex/interfaces" #change this path only - all other paths are... (3 Replies)
Discussion started by: viallos
3 Replies

4. 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

5. Shell Programming and Scripting

TEST Command

Hello, I need help with a test command. Here is what I am trying to do : I've got an interactive script that check if configuration files exist on 2 different directories, then all configuration files are print on screen by a short name. My problem is when you type a "wrong name" or... (12 Replies)
Discussion started by: Aswex
12 Replies

6. Shell Programming and Scripting

How to check weather a string is like test* or test* ot *test* in if condition

How to check weather a string is like test* or test* ot *test* in if condition (5 Replies)
Discussion started by: johnjerome
5 Replies

7. Shell Programming and Scripting

Test on string containing spacewhile test 1 -eq 1 do read a $a if test $a = quitC then break fi d

This is the code: while test 1 -eq 1 do read a $a if test $a = stop then break fi done I read a command on every loop an execute it. I check if the string equals the word stop to end the loop,but it say that I gave too many arguments to test. For example echo hello. Now the... (1 Reply)
Discussion started by: Max89
1 Replies

8. Shell Programming and Scripting

TEST command

I have been looking into searching various files to display output. The search criteria will be a month and year to output various numbers in the files. is there any way to do this with the TEST function or would it have to be another way? (4 Replies)
Discussion started by: amatuer_lee_3
4 Replies

9. AIX

Test command

Hello, I am trying to add some tests to existing code. The code already contains some test commands. An example is as follows... ] then Does anyone know the purpose of the double equals? I would have used a single equals sign... (2 Replies)
Discussion started by: JWilliams
2 Replies

10. UNIX for Dummies Questions & Answers

the TEST command

Hi everyone, I am new to UNIX and scripting, and I have some problems with the test command. when i try to execute the command: test 20070327.gz > 20070320.gz i try to make a charachter string comparison between the two strings or the two files, to make sure that 20070327.gz is greater than... (2 Replies)
Discussion started by: marwan
2 Replies
Login or Register to Ask a Question