test isn't even a shell builtin. They couldn't possibly depreciate -a. They can roll their eyes and sigh at people who use it, but it's not going away.
Not everyone has the luxury of a POSIX compliant shell, either. Don't make me lecture you for not using PAX instead of tar -- that's the better, POSIX way to do archiving now
Posix "standards" changes year-on-year over the decades and have the occasional touch of madness in threatening to depreciate feature which are in widespread use in manufacture-supplied system scripts as well as custom scripts.
I prefer the "-a" and "-o" syntax myself compared with the ancient "&&" and "||" syntax. Those with a bias towards "C" and "awk" seem to prefer the older syntax. I do use "&&" and "||" in crontab but without a leading "if".
It's about 50-50 in the system scripts which come with my system.
From the moment Posix didn't include compatibility settings with other Bourne-like Shells we found machines shipped with multiple alternate Shells and manufacturers offering downloads of alternate Shells.
I love the this line from the Wikipedia on Posix:
Quote:
The following operating systems conform (i.e., are 100% compliant) to one or more of the various POSIX standards.
test isn't even a shell builtin. They couldn't possibly depreciate -a. They can roll their eyes and sigh at people who use it, but it's not going away.
Not everyone has the luxury of a POSIX compliant shell, either. Don't make me lecture you for not using PAX instead of tar -- that's the better, POSIX way to do archiving now
No, obviously, it will not go away entirely, but that is not what deprecation means. Of course anyone can keep using whatever they like. But is it is good practice on this forum to show solutions that work across platforms and the best guarantee for that is POSIX. I hardly think think pointing that out can be seen as "lecturing".
Apparently there are reasons for obsolescing -a and -o . They are explained here: test: application usage
Also, test is a shell builtin as well as an external program in practically any shell nowadays. POSIX requires that regular built-in commands also exist as separate binaries.
That is why the use of ampersands to connect tests statements isn't detrimental to speed anymore..
What systems are you using that do not have a "luxury" POSIX compliant shell? Solaris?
---------- Post updated at 08:04 ---------- Previous update was at 07:46 ----------
Quote:
Originally Posted by methyl
Posix "standards" changes year-on-year over the decades and have the occasional touch of madness in threatening to depreciate feature which are in widespread use in manufacture-supplied system scripts as well as custom scripts.
I prefer the "-a" and "-o" syntax myself compared with the ancient "&&" and "||" syntax. Those with a bias towards "C" and "awk" seem to prefer the older syntax. I do use "&&" and "||" in crontab but without a leading "if".
It's about 50-50 in the system scripts which come with my system.
From the moment Posix didn't include compatibility settings with other Bourne-like Shells we found machines shipped with multiple alternate Shells and manufacturers offering downloads of alternate Shells.
I love the this line from the Wikipedia on Posix:
The reason I prefer this syntax is not because of C or awk, but because it conforms to POSIX recommendations plus apparently there are reasons for avoiding -o and -a.
Last edited by Scrutinizer; 02-28-2012 at 05:41 AM..
This User Gave Thanks to Scrutinizer For This Post:
Hi people,
I would like to start a review of my config variable to check whether they have been changed and if not then there is only an echo. If they have been changed to my other commands are executed.
I hope you can help me.
with best regards
JPad
edit:
here my code
if ;... (8 Replies)
I have a script /root/asas with following contents.
#!/bin/bash
ha=`cat /etc/passwd | grep sandra`
if ; then
echo "Sandra is in /etc/passwd"
echo "variable ha is $ha"
else
echo "Sandra is NOT in /etc/passwd"
echo "variable ha is $ha"
fi
What... (3 Replies)
Hi all,
I want to use a variable inside my sql query and below is my script:
#!/bin/ksh
export b="abcd"
a=`sqlplus -s abc/def@ghi <<++
set heading off;
set feedback off;
select xxx from mytable where clmn_nm='$b';
exit;
++`
echo $a
But the output i get is below:
$>... (4 Replies)
#!/bin/sh
echo "Running Script to capture ORACLE Erros"
# Change Directory to the actual logs path
cd /home/nv8510/lognew
err_var=`grep -in "ORA-" *`
if then
echo "THESE ARE THE ORACLE ERROR OCCURED"
echo "$err_var"
echo... (7 Replies)
I have seen many posts for this sort of problem but I just did not know how to use it for my issue. A number is assigned to a variable and I wanted to check if it is a zero or non zero.
Example of my numbers are below:
000000000000000000000000000000000000000000000000... (8 Replies)
Hi all,
What is the simplest way to setting a variable to $1 if it exists ?
If I go with name=${"$1":-abc}, bash complains "bad substitution",
So I use
name="$1"
name=${name:-abc}
But is there a way to fix this "bad substitution" ?
Thanks! (2 Replies)
Hello,
I want to checkl whether my file has text in it or not.
if ; then
...
if ; then
...
But none of these work
Can someone help me?
---------- Post updated at 09:00 AM ---------- Previous update was at 08:55 AM ----------
The code-tags caused an displayerror,... (5 Replies)
Hi
I am writing a bash script and would like to check is a variable contains a . or not
ex.
a=102 output ok
a=1.02 output not ok
Many thanks, (3 Replies)
if test $b -ne
then
echo "\n\n\n\tPassword reset has been done successfully"
else
echo "\n\n\n\tAn error occurred"
fi
i want to check whether $b is non-numeric so how to do that? (3 Replies)
hi,
pls could you help me with one program in KSH ( i have sunOS).
I need to create an If clause, that prints an error message and filenames, when in a directory are found some files of null size (find . -type f -size 0 ).
thanks (3 Replies)