Skip to content

Commit

Permalink
src/data/listDvdDrive: Rewrite script for better readability
Browse files Browse the repository at this point in the history
Other changes:
* Use portabler shebang

Signed-off-by: 林博仁 <[email protected]>
  • Loading branch information
brlin-tw committed Jun 9, 2017
1 parent ca5895a commit 1e2b657
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions src/data/listDvdDrive
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

0 comments on commit 1e2b657

Please sign in to comment.