From 3d5aeb2be0586bfc9fdbc9b67827faa3d8f0a359 Mon Sep 17 00:00:00 2001 From: Jephte Clain Date: Mon, 9 May 2016 18:46:39 +0400 Subject: [PATCH] =?UTF-8?q?Ajouter=20l'option=20-c=20=C3=A0=20umountr?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- umountr | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/umountr b/umountr index 9d65746..00c5a1a 100755 --- a/umountr +++ b/umountr @@ -11,10 +11,18 @@ USAGE Démonter tous les systèmes de fichiers qui sont montés en-dessous de mountpoint puis démonter mountpoint. Démonter aussi tous les systèmes de fichiers -bind-montés à partir d'un sous-répertoire de mountpoint." +bind-montés à partir d'un sous-répertoire de mountpoint. + +OPTION + -c, --continuous + Continuer même en cas d'erreur" } -args=(--help '$exit_with display_help') +continuous= +args=( + --help '$exit_with display_help' + -c,--continuous continuous=1 +) parse_args "$@"; set -- "${args[@]}" mountp="$1" @@ -22,7 +30,7 @@ mountp="$1" [ -d "$mountp" ] || die "$mountp: répertoire introuvable" setx mountp=abspath "$mountp" -run_as_root "$@" +run_as_root ${continuous:+-c} "$@" setx -a mountps=findmnt -nlo TARGET array_contains mountps "$mountp" || die "Vous devez spécifier un répertoire de montage valide" @@ -31,12 +39,17 @@ function show_all() { findmnt -T "$mountp" -Rnlo TARGET findmnt -nlo TARGET | awkrun mountp="$mountp" '{ if (substr($0, 1, length(mountp) + 1) == (mountp "/")) print }' } +function die_maybe() { + [ -n "$continuous" ] && return + die "$@" +} setx -a mounts=evalp show_all // sort -u // \ awk '{print length($0) "," $0}' // \ sort -nr // \ awk '{sub(/[0-9]+,/, ""); print}' + for mount in "${mounts[@]}"; do estep "$mount" - umount "$mount" || die + umount "$mount" || die_maybe done