diff options
| author | Raymaekers Luca <raymaekers.luca@gmail.com> | 2023-09-11 12:56:47 +0200 | 
|---|---|---|
| committer | Raymaekers Luca <raymaekers.luca@gmail.com> | 2023-09-11 12:56:47 +0200 | 
| commit | 1f96a1175c292a4e86a49a1874e070cbcfee6607 (patch) | |
| tree | ffb62b4b6156a681c9e514e99695898c2daa388d /bin/common/aumount | |
| parent | 4b94f7b02b39f8ea702f7afa24899aa36a10d705 (diff) | |
[aumount] use logn instead of die
Diffstat (limited to 'bin/common/aumount')
| -rwxr-xr-x | bin/common/aumount | 23 | 
1 files changed, 10 insertions, 13 deletions
diff --git a/bin/common/aumount b/bin/common/aumount index 32d221c..cbc5c8b 100755 --- a/bin/common/aumount +++ b/bin/common/aumount @@ -3,20 +3,17 @@  tmp="$(mktemp)"  test "$(id -u)" != "0" && sudo="sudo" -die () -{ -	echo "$@" >&2 -} +logn () { >&2 printf "%s\n" "$@"; }  # Read one character  read_char ()  { -	die -n ">" +	logn -n ">"  	old_stty_cfg=$(stty -g)  	stty raw  	dd ibs=1 count=1 2> /dev/null  	stty "$old_stty_cfg" -	die "" +	logn ""  }  get_dev () { grep "^$1\." "$tmp" | cut -f 2- -d ' '; } @@ -27,7 +24,7 @@ mount ()  	dev="$(get_dev "$1")"  	test -z "$dev" && exit 1 -	die "Mounting /dev/$dev on /media/$dev" +	logn "Mounting /dev/$dev on /media/$dev"  	mkdir -p /media/"$dev"  	$sudo mount /dev/"$dev" /media/"$dev" > /dev/null 2>&1 ||  		return 1 @@ -39,7 +36,7 @@ umount ()  	mountpoint="$(sed -n "${1}p" "$tmp" | awk '{print $3}')"  	test -z "$mountpoint" && exit 1 -	die "Unmounting $mountpoint" +	logn "Unmounting $mountpoint"  	$sudo umount "$mountpoint" ||  		return 1  } @@ -49,7 +46,7 @@ ejekt ()  	dev="$(get_dev "$1" | sed 's/.$//')"  	test -z "$dev" && exit 1 -	die "Ejecting /dev/$dev" +	logn "Ejecting /dev/$dev"  	$sudo eject /dev/"$dev" > /dev/null 2>&1 ||  		return 1  } @@ -59,7 +56,7 @@ pr_lsblk ()  {  	clear  	lsblk -o name,size,type,mountpoint -	die "───────────────────────────────────" +	logn "───────────────────────────────────"  	lsblk --ascii -o name,mountpoint |  		grep '^.-' |  		while read -r line @@ -77,7 +74,7 @@ cleanup () { rm -f "$tmp"; }  trap cleanup EXIT INT -die "m(ount) u(mount) (e)ject ?" +logn "m(ount) u(mount) (e)ject ?"  choice="$(read_char)"  case $choice in @@ -93,7 +90,7 @@ printf "%s" "$choice" | grep -q "[0-9]" || exit 1  if $cmd "$choice"  then -	die "Successful." +	logn "Successful."  else -	die "Failed." +	logn "Failed."  fi  | 
