Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deal with unicode box drawings in snapper's output #120

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

martyone
Copy link

No description provided.

@@ -366,7 +366,7 @@ for x in $selected_configs; do
BACKUPDIR="$selected_mnt/$mybackupdir"
$ssh test -d "$BACKUPDIR" || $ssh btrfs subvolume create "$BACKUPDIR"
else
mybackupdir=$(snapper -c "$x" list -t single | awk -F"|" '/'"subvolid=$selected_subvolid, uuid=$selected_uuid"'/ {print $5}' | awk -F "," '/backupdir/ {print $1}' | awk -F"=" '{print $2}')
mybackupdir=$(snapper -c "$x" list -t single | sed 's/│/|/g' | awk -F"|" '/'"subvolid=$selected_subvolid, uuid=$selected_uuid"'/ {print $5}' | awk -F "," '/backupdir/ {print $1}' | awk -F"=" '{print $2}')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of replacing the Unicode character, it might be cleaner to not produce it in the first place by executing Snapper with LC_ALL=C:

mybackupdir=$(LC_ALL=C snapper -c "$x" list -t single | awk -F"|" '/'"subvolid=$selected_subvolid, uuid=$selected_uuid"'/ {print $5}' | awk -F "," '/backupdir/ {print $1}' | awk -F"=" '{print $2}')

(This might be something to consider at other places in the script too where the output of a command line tool is processed by the script.)

Additionally/alternatively, it might make sense to immediately restrict the output to the relevant column; however, this might not be backwards-compatible with older versions of Snapper:

mybackupdir=$(LC_ALL=C snapper -c "$x" list --columns userdata -t single | grep -F "subvolid=$selected_subvolid, uuid=$selected_uuid" | awk -F "," '/backupdir/ {print $1}' | awk -F"=" '{print $2}')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants