From 1f57a0d47b67a966ec0a2de0e83348fd41b478bc Mon Sep 17 00:00:00 2001 From: PowerUser64 Date: Tue, 17 Aug 2021 15:26:46 -0700 Subject: [PATCH] improved regex with a look-behind zero-width assertion --- .local/bin/dotfiles-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.local/bin/dotfiles-install.sh b/.local/bin/dotfiles-install.sh index 485522e..0476af9 100755 --- a/.local/bin/dotfiles-install.sh +++ b/.local/bin/dotfiles-install.sh @@ -26,7 +26,7 @@ if dot checkout > /dev/null 2>&1; then else echo "Backing up pre-existing dotfiles." # get the list of files that need to be backed up - DOTFILES_BACKUP_LIST=($(dot checkout 2>&1 | grep -Po "\t.*$" | cut -c 1 --complement)) + DOTFILES_BACKUP_LIST=($(dot checkout 2>&1 | grep -Po "(?<=\t)(.*)$")) # create directories for everything that needs one mkdir -p "$DOTFILES_BACKUP_DIR" $(printf '%s\n' "${DOTFILES_BACKUP_LIST[@]}" | grep -Po '.*/' | sed "s#.*#$DOTFILES_BACKUP_DIR/&#g") # backup the files to avoid them being overwritten