Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ inputPath="{{ .TargetPath }}"
if [[ "$inputPath" = /* ]]; then
targetPath="$inputPath"
else
targetPath="$(pwd)/$inputPath"
# Use the owner's home directory as the base for relative paths
# The owner is in format user:group, we need only the user part
targetPath="$(printf ~{{ .Owner }} | cut -d':' -f1)/$inputPath"
Copy link

Choose a reason for hiding this comment

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

Bug: Tilde Expansion Fails After Template Substitution

The tilde expansion will not work as intended. The command printf ~{{ .Owner }} does not perform tilde expansion because printf receives its arguments after the template substitution occurs. When {{ .Owner }} is substituted with a value like "user:group", the result is printf ~user:group, which printf will output as the literal string "~user:group" without expanding it to the home directory. The subsequent cut -d':' -f1 will then extract "~user" from this literal string, not an actual home directory path. This means targetPath will be set to something like "~user/relativepath" instead of the actual home directory path like "/home/user/relativepath". The correct approach would be to extract the username first, then use eval or getent to properly expand the home directory.

Fix in Cursor Fix in Web

fi

cd "$sourceFolder" || exit 1
Expand Down