[suggestion] emulate readlink using posix ls#5
[suggestion] emulate readlink using posix ls#5smoon8 wants to merge 3 commits intomkropat:masterfrom
Conversation
realpath.sh
Outdated
| } | ||
|
|
||
| _posix_ls_readlink() { | ||
| LC_TIME=POSIX ls -l -- "$1" | sed -e 's/^.\{11\}\ *[0-9]\{1,\}\ *[a-zA-Z\._@\$-]\{1,\}\ *[a-zA-Z\._@\$-]\{1,\}\ *[0-9]\{1,\}\ *[^ ]*\ *[0-9]\{1,2\}\ *[^\ ]*\ \(.*\)/\1/g' -e 's/.* -> //g' 2>/dev/null |
There was a problem hiding this comment.
Wow, it'll take me a little bit to wrap my head around that regex.
Does the g flag do anything when the substitution match is anchored to the beginning of the line with ^?
There was a problem hiding this comment.
the g flag does nothing. it's just my habbit when i write regex.
|
Thanks for the PR! I think you're right, Do you see any reason to keep around the stat readlink emulation? I'm inclined to get rid of it if there's ls readlink emulation. Also, it might be nice to have an automated test or two around this change, but I'm not super worried about it since it's a bonus feature that's basically a big regex. I can test this out and verify that it seems to work right sometime in the next few days. Or if someone else wants to try it out and vouch for the change, I'd consider merging it sooner. |
|
the ls readlink emulation is just suggestion. so i didnt consider removing the stat readlink emulation. and i was careless about an automated test. it's my fault. i'll add automated test soon. i didnt usually pay attention about automated test. if i may, can i ask you an advice while i add an automated test? |
ls(1) stderr redirect to /dev/null
bugfix posix_ls_readlink
stat(1) is not posix compatible.
emulated readlink using ls