-
Notifications
You must be signed in to change notification settings - Fork 307
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
src/data/listDvdDrive: Rewrite script for better readability
Other changes: * Use portabler shebang Signed-off-by: 林博仁 <[email protected]>
- Loading branch information
Showing
1 changed file
with
19 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,25 @@ | ||
#!/bin/bash | ||
|
||
# Config | ||
# Le script quitte en cas d'erreur d'une commande | ||
#!/usr/bin/env bash | ||
## Makes debuggers' life easier - Unofficial Bash Strict Mode | ||
## BASHDOC: Shell Builtin Commands - Modifying Shell Behavior - The Set Builtin | ||
set -o errexit | ||
|
||
# Le script quitte en cas de variables non déclarée | ||
set -o errtrace | ||
set -o nounset | ||
set -o pipefail | ||
|
||
declare optical_disk_drive_devfs_path | ||
|
||
while read path; do | ||
if echo "$path" | grep '/block/sr' > /dev/null; then | ||
devName="/dev/$(basename "$path")" | ||
echo "$devName" | ||
echo "$devName - $(cat "$path/device/model")" | ||
while read sysfs_block_device_path; do | ||
if echo "${sysfs_block_device_path}"\ | ||
| grep '/block/sr' > /dev/null; then | ||
optical_disk_drive_devfs_path="/dev/$(basename "${sysfs_block_device_path}")" | ||
echo "${optical_disk_drive_devfs_path}" | ||
echo "${optical_disk_drive_devfs_path} - $(cat "${sysfs_block_device_path}/device/model")" | ||
fi | ||
done < <(find /sys/block -maxdepth 1 -mindepth 1) | ||
done < <(\ | ||
find\ | ||
/sys/block\ | ||
-maxdepth 1\ | ||
-mindepth 1\ | ||
) | ||
|
||
exit 0 |