From 0b0cd477c559ae159d3325922fc5b06cf34afb5d Mon Sep 17 00:00:00 2001 From: Hippolyte Chauvin Date: Thu, 13 Apr 2023 00:57:54 +0200 Subject: [PATCH] =?UTF-8?q?L=C3=A9g=C3=A8re=20r=C3=A9=C3=A9criture=20de=20?= =?UTF-8?q?updateall?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/updateall | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/bin/updateall b/bin/updateall index 1a6ee01..dbd3ae9 100755 --- a/bin/updateall +++ b/bin/updateall @@ -1,24 +1,26 @@ #!/bin/bash # Variable -commands_d="$HOME/.local/share/updateall/commands.d" +commands_d="${HOME}/.local/share/updateall/commands.d" # Function # Create a clear separator, adapts to the screen size function separator { - local char="${2:-=}" - local separator cols + local separator="" + + local name="$1" ; shift + local char="${1:-=}"; shift (( cols = $(tput cols) / 3 )) - while [[ ${#separator} -le $cols ]]; do + while [[ ${#separator} -le "$cols" ]]; do separator+="$char" done - printf '\n%s\n\t%s\n%s\n' "$separator" "$1" "$separator" + printf '\n%s\n\t%s\n%s\n' "$separator" "$name" "$separator" } # Loop -for pm in "$commands_d/"*; do +for pm in "${commands_d}/"*; do separator "$(basename "$pm")" source "$pm" done