Skip to content

Commit

Permalink
use command -v instead of type and which
Browse files Browse the repository at this point in the history
  • Loading branch information
Mrfai committed Sep 18, 2019
1 parent 8724676 commit eed26f8
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
6 changes: 3 additions & 3 deletions bin/fai-cd
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ error_space() {
check_programs() {

local msg
[ $squash_only -eq 1 -o -x "$(which xorriso)" ] || msg+="xorriso not found. Please install package."
[ -x "$(which mksquashfs)" ] || msg+="\nmksquashfs not found. Please install the package squashfs-tools."
[ -x "$(which parted)" ] || msg+="\ncommand parted not found. Please install package parted."
[ $squash_only -eq 1 ] && command -v xorriso >&/dev/null || msg+="xorriso not found. Please install package."
command -v mksquashfs >&/dev/null || msg+="\nmksquashfs not found. Please install the package squashfs-tools."
command -v arted >&/dev/null || msg+="\ncommand parted not found. Please install package parted."

if [ -n "$msg" ]; then
die 8 "$msg"
Expand Down
8 changes: 4 additions & 4 deletions bin/fai-diskimage
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ supported: .raw.xz, .raw.zst, .qcow2, .vdi, .vhdx, .vmdk, .simg.
check_commands() {

local error=0
if ! type qemu-img > /dev/null 2>&1; then
if ! command -v qemu-img >&/dev/null; then
echo "qemu-img not found. Install the package qemu-utils."
error=1
fi
if ! type setup-storage > /dev/null 2>&1; then
if ! command -v setup-storage >&/dev/null; then
echo "setup-storage not found. Install the package fai-setup-storage."
error=1
fi
Expand Down Expand Up @@ -159,7 +159,7 @@ case $ext in
;;
simg) convert=2
cmd="img2simg $rawname $iname.simg"
if ! type img2simg > /dev/null 2>&1; then
if ! command -v img2simg >&/dev/null; then
echo "img2simg not found. Install the package img2simg."
error=1
fi
Expand Down Expand Up @@ -199,7 +199,7 @@ if [ $(id -u) != "0" ]; then
die 1 "Run this program as root."
fi

if type vgs >/dev/null 2>&1; then
if command -v vgs >&/dev/null; then
export SS_IGNORE_VG=$(vgs --unbuffered --noheadings -o name --rows)
fi

Expand Down
4 changes: 2 additions & 2 deletions bin/fai-make-nfsroot
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ call_debootstrap() {
fi
fi
if [ $_debootstrap = "qemu-debootstrap" ]; then
if ! type -P $_debootstrap >/dev/null; then
if ! command -v $_debootstrap >&/dev/null; then
die 1 "qemu-debootstrap not found. Please install the package qemu-user-static."
fi
fi
Expand Down Expand Up @@ -327,7 +327,7 @@ add_etc_hosts_entries() {
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
create_base() {

[ ! -x "$(which debootstrap)" ] && die 1 "Can't find debootstrap command. Aborting."
command -v debootstrap >&/dev/null || die 1 "Can't find debootstrap command. Aborting."
call_debootstrap $FAI_DEBOOTSTRAP
$ROOTCMD apt-get clean
rm -f $NFSROOT/etc/resolv.conf $NFSROOT/etc/hostname $NFSROOT/etc/udev/rules.d/70-persistent-net.rules
Expand Down
2 changes: 1 addition & 1 deletion bin/fai-mirror
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ export NFSROOT
if [ -n "$csdir" ]; then
FAI_CONFIGDIR=$csdir # override by -s
fi
[ -x "$(which reprepro)" ] || die 8 "reprepro not found. Please install the package."
command -v reprepro >&/dev/null || die 8 "reprepro not found. Please install the package."
[ -n "$exclasses" -a -n "$cclasses" ] && die 3 "Options -x and -c not allowed at the same time."

# use first argument if given, use variable mirrordir if not argument was given
Expand Down
2 changes: 1 addition & 1 deletion dev-utils/fai-mk-network
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ if [ $(id -u) != "0" ]; then
usage
fi

if [ ! -x "$(which brctl)" ]; then
if ! command -v brctl >&/dev/null; then
echo "brctl not found. Please install bridge-utils."
exit 3
fi
Expand Down
2 changes: 1 addition & 1 deletion lib/subroutines
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,7 @@ call_debootstrap() {
fi
done
if [ $_debootstrap = "qemu-debootstrap" ]; then
if ! type -P $_debootstrap >/dev/null; then
if ! command -v $_debootstrap >&/dev/null; then
die 1 "qemu-debootstrap not found. Please install the package qemu-user-static."
fi
fi
Expand Down
10 changes: 5 additions & 5 deletions lib/task_sysinfo
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ cd /sys/class/dmi/id
grep . {board_,bios_,product_}* 2>/dev/null| sed -e 's/:/: /'| egrep -iv '123456789|To Be Filled|: Not |N/A|:[[:blank:]]+$'
cd - >/dev/null

if [ -x "$(which lshw)" ]; then
if command -v lshw >&/dev/null; then
lshwtmp=$(mktemp)
lshw -short -quiet -C system,memory,processor,display,storage,disk | tee $lshwtmp
echo
Expand All @@ -29,7 +29,7 @@ echo "NUMA configuration:"
numactl -H

echo
if [ -x "$(which hwinfo)" ]; then
if command -v hwinfo >&/dev/null; then
hwinfo --short --cpu --sys
hwinfo --short --smp
hwinfo --short --bios
Expand All @@ -56,7 +56,7 @@ echo "Now more detailed information"
echo '=================================================='

lspci
[ -x "$(which sfdisk)" ] && sfdisk -d
command -v sfdisk >&/dev/null && sfdisk -d

#[ -f /proc/scsi/scsi ] && cat /proc/scsi/scsi

Expand All @@ -76,8 +76,8 @@ find /dev/disk/by-id ! -type d -printf "%-40f\t-> %l\n" | grep -v part | sort -
echo
cat /proc/partitions

[ -x "$(which lsblk)" ] && lsblk -i
[ -x "$(which blkid)" ] && blkid
command -v lsblk >&/dev/null && lsblk -i
command -v blkid >&/dev/null && blkid

# very detailed
for disk in $disklist; do
Expand Down

0 comments on commit eed26f8

Please sign in to comment.