Skip to content

Commit

Permalink
Fix user path reg query potentially getting truncated
Browse files Browse the repository at this point in the history
The reg query command used returns a multi-line output that contains the path variable's content in its third line:
    Path    REG_EXPAND_SZ    [actual path variable]
The previous code just returned the last column of that line using awk, which fails to account
for spaces in the path, in which case only the part after the last space was printed.
Now cut is used to skip the first 12 spaces and print every after it, which returns the entire path variable's content unmodified.

Signed-off-by: Moritz Bender <35152647+Morilli@users.noreply.github.com>
  • Loading branch information
Morilli committed Jun 7, 2024
1 parent 5fd7f09 commit bbde477
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion git-extra/getgit
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ echo "be removed from the context menu is available as $rm_ctxmenu "
echo ""
# Setting ENV
echo -n "Setting env ..."
userpath=$(reg query "HKEY_CURRENT_USER\Environment" //v Path 2>/dev/null | awk 'NR==3 {print $NF}')
userpath=$(reg query "HKEY_CURRENT_USER\Environment" //v Path 2>/dev/null | awk 'NR==3 {print}' | cut -d ' ' -f 13-)
if [[ "$userpath" == "" ]]; then
setx PATH "$(cygpath -m /cmd)" > /dev/null 2>&1
elif [[ "$userpath" != *"$(cygpath -m /cmd)"* ]]; then
Expand Down

0 comments on commit bbde477

Please sign in to comment.