mirror of
https://github.com/PowerShell/openssh-portable.git
synced 2025-07-29 16:54:51 +02:00
Convert "have_prog" function into "which".
"which" and its behaviour is not standardized, so convert the existing have_prog function into "which" so we can rely on it being available and what its semantics are. Add a have_prog wrapper that maintains the existing behaviour.
This commit is contained in:
parent
ea7ecc2c3a
commit
f69319ad8a
@ -320,7 +320,7 @@ export SSH_PKCS11_HELPER SSH_SK_HELPER
|
|||||||
#echo $SSH $SSHD $SSHAGENT $SSHADD $SSHKEYGEN $SSHKEYSCAN $SFTP $SFTPSERVER $SCP
|
#echo $SSH $SSHD $SSHAGENT $SSHADD $SSHKEYGEN $SSHKEYSCAN $SFTP $SFTPSERVER $SCP
|
||||||
|
|
||||||
# Portable specific functions
|
# Portable specific functions
|
||||||
have_prog()
|
which()
|
||||||
{
|
{
|
||||||
saved_IFS="$IFS"
|
saved_IFS="$IFS"
|
||||||
IFS=":"
|
IFS=":"
|
||||||
@ -328,13 +328,21 @@ have_prog()
|
|||||||
do
|
do
|
||||||
if [ -x $i/$1 ]; then
|
if [ -x $i/$1 ]; then
|
||||||
IFS="$saved_IFS"
|
IFS="$saved_IFS"
|
||||||
|
echo "$i/$1"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
IFS="$saved_IFS"
|
IFS="$saved_IFS"
|
||||||
|
echo "$i/$1"
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
have_prog()
|
||||||
|
{
|
||||||
|
which "$1" >/dev/null 2>&1
|
||||||
|
return $?
|
||||||
|
}
|
||||||
|
|
||||||
jot() {
|
jot() {
|
||||||
awk "BEGIN { for (i = $2; i < $2 + $1; i++) { printf \"%d\n\", i } exit }"
|
awk "BEGIN { for (i = $2; i < $2 + $1; i++) { printf \"%d\n\", i } exit }"
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user