Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support -n (--no-newline) option #5

Open
ko1nksm opened this issue May 9, 2021 · 0 comments
Open

Support -n (--no-newline) option #5

ko1nksm opened this issue May 9, 2021 · 0 comments

Comments

@ko1nksm
Copy link
Owner

ko1nksm commented May 9, 2021

I found out here that the minimal implementation of readlink has the -f and -n options.

https://man.openbsd.org/readlink.1

The readlink utility when invoked with the pathname of a symbolic link as its argument dereferences the symbolic link and prints the name of target on standard output. If the -f option is not specified and readlink is invoked with an argument other than the pathname of a symbolic link, it exits with a nonzero exit code without printing anything.

The options are as follows:

-f
Canonicalize by following every symlink in every component of the given path recursively. readlink will resolve both absolute and relative paths and return the absolute pathname corresponding to file. The argument does not need to be a symbolic link.
-n
Do not print a trailing newline character.

I will support the -n option because it is needed when handling correctly with filenames ending in newline. To be precise, I will create readlinkfn function instead of adding a option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant