Deal with unicode box drawings in snapper's output#120
Open
martyone wants to merge 1 commit intobaodrate:masterfrom
Open
Deal with unicode box drawings in snapper's output#120martyone wants to merge 1 commit intobaodrate:masterfrom
martyone wants to merge 1 commit intobaodrate:masterfrom
Conversation
Flupp
reviewed
Jan 4, 2025
| $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}') |
There was a problem hiding this comment.
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}')
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.