Use the -f flag instead of -m flag for readlink #26
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.
The
-m
flag isn't as portable as I thought. According to Mark Altmann, the-m
is not available on older Mac systems, and may not be available on BSD.The
-f
flag should be more universal.I'll test to make sure all things work as they did, until then I'll leave this as a draft.
Edit: Here's a list of things I tested:
test4/mosquitto_config.tar.gz
) contains a link to itself (e.g.test4 -> test4
),readlink
with-m
returns the path to the link (e.g./home/user/directory/test4
), while with-f
it returns an empty string. Either case results in a Docker error, though different ones.test5/mosquitto_config.tar.gz
, both-m
and-f
correctly resolve to/home/user/directory/test3
)rm -rf test3
in the above case before exporting), though this will create that missing directorytest6 -> test6.1
andtest6.1 -> test3
when destination istest6/bitwarden_data.tar.gz
)-m
works but -ffails (e.g.
test7 -> test3and destination is
test3/test/mosquitto_config.tar.gz, but
test3doesnt exist (
rm -rf test3), then
-mreturns the correct path
/home/user/directory/test3/test, but
-f` return an empty string)Overall, the main difference, from what I can tell, is that
-f
will faill if a link in the middle of the destination path points to an invalid object, wheres-m
works, which was the reason of using it in the first place:If we use
-f
, might be worth erroring out with a better message whenreadlink
returns an empty string. I'll add that if you agree with that.