sh -> csh conversion problem

sh -> csh conversion problem

Post by Juha Lai » Sat, 25 Nov 1995 04:00:00



Does csh have any nice equivalent to the following sh expression? Any
help/workarounds appreciated.

Quoted from HP-UX sh-bourne(1), concerning shell variable substitution.

:      ${parameter:=word}
:                     If parameter is not set or is null, set it to word; the
:                     value of the parameter is then substituted.  Positional
:                     parameters cannot be assigned to in this way.

Thank you,
--
Juha Laiho, Nokia Telecommunications - not speaking for my employer

 
 
 

sh -> csh conversion problem

Post by Gary M. Greenbe » Sat, 25 Nov 1995 04:00:00




> Does csh have any nice equivalent to the following sh expression? Any
> help/workarounds appreciated.

> Quoted from HP-UX sh-bourne(1), concerning shell variable substitution.

> :      ${parameter:=word}
> :                     If parameter is not set or is null, set it to word; the
> :                     value of the parameter is then substituted.  Positional
> :                     parameters cannot be assigned to in this way.

> Thank you,
> --
> Juha Laiho, Nokia Telecommunications - not speaking for my employer

In csh, $?parameter yields 1 (true) if set and 0 (false) if not set.

C'ya,

gary /* the Sorcerer's Apprentice */

"Why do we have to hide from the police, Daddy?" | Truth:
"Because we use vi, honey. They use emacs."      | This .sig is pirated

 
 
 

1. Script conversion from csh --> sh

I have just installed xv3.00. The Makefiles invoke './RANLIB.csh'
(seen below) ...

==> RANLIB.csh <==
#!/bin/csh -f
#
# tests to see if the program 'ranlib' exists.  If it does, runs ranlib on
# the first argument (a library name).  Otherwise, does nothing, and returns
#
# written by John Bradley for the XV 3.00 release
# thanks to John Hagan for shell-script hackery
#

echo "executing 'ranlib $1'..."

# Is there a ranlib?  Let's try and then suffer the consequences...
set haveranlib = `ranlib $1 >& /dev/null`

if ( $status ) then
        echo "There doesn't seem to be a ranlib on this system..."
        echo "Don't worry about it."
endif

echo ""
echo ""
==> END: RANLIB.csh <==

Under LINUX i'm only used in using 'bash'. So I try to convert the script
for bash. NOW MY QUESTION: Are the scripts equivalent??

==> RANLIB.sh <==
#    #!/bin/csh -f
#
# tests to see if the program 'ranlib' exists.  If it does, runs ranlib on
# the first argument (a library name).  Otherwise, does nothing, and returns
#
# written by John Bradley for the XV 3.00 release
# thanks to John Hagan for shell-script hackery
#

echo "executing 'ranlib $1'..."

# Is there a ranlib?  Let's try and then suffer the consequences...
haveranlib=`ranlib $1 > /dev/null 2>&1`
STATUS=$?

# echo haveranlib = XXX${haveranlib}XXX
# echo STATUS = $STATUS

if test $STATUS -ne 0 ; then
        echo "There doesn't seem to be a ranlib on this system..."
        echo "Don't worry about it."
fi

echo ""
echo ""
==> END: RANLIB.sh <==

Thanx
Thomas
--
Thomas Grunenberg, Kirchhofallee 12, 2300 Kiel 1, (24103 Kiel)

2. Which lines to comment out goodstuff and pager?

3. set conversion sh > csh

4. Sound Blaster in Linnux

5. csh to sh conversion utility

6. list_for_each_entry

7. sh var -> awk var -> sh var

8. 156 key keyboard

9. csh -> ksh or ksh -> csh EQUIVALENTS NEEDED....

10. ksh -> sh conversion???

11. Conversion/Utility Unix .sh -> mac?

12. sh->xqf->quake works, fvwm->xqf->quake hangs X?

13. help: csh -> sh