Add -d option to basename to output directory name
This commit introduces a new -d command-line option to the basename utility. When this option is used, basename will output the directory portion of the given path, similar to the dirname command.
The -d option is mutually exclusive with the existing -a (multiple arguments) and -s (suffix) options. If -d is used in combination with either -a or -s, or if multiple path arguments are provided with -d, basename will print a usage error and exit.
The following changes were made:
- Modified
usr.bin/basename/basename.cto implement the-doption, including error handling for conflicting options. - Updated the usage message in
basename.cto include the new option. - Updated the manual page
usr.bin/basename/basename.1to document the-doption, its behavior, and its mutual exclusivity with other options. - Added a new test script
usr.bin/basename/tests/basename_test.shwith comprehensive test cases for the new-doption and to ensure existing functionality remains unaffected. Test cases cover various path types, trailing slashes, root paths, empty strings, and option conflicts. Signed-off-by: Recep Karahan [email protected]
Thank you for taking the time to contribute to FreeBSD! There are a few issues that need to be fixed:
- Missing Signed-off-by lines0b84642fa5c09d5eff01c3aa9daedb037cfacf4b
- Real email address is needed0b84642fa5c09d5eff01c3aa9daedb037cfacf4b
Please don't spam our repository with AI-generated slop. It serves only to waste our time and yours. After reviewing some of your PRs, I have concluded that the rest do not warrant even a cursory review. Therefore I will close them all. If you wish to contribute again in the future, you must take more care with your submissions. You must build and test them all, at least! And you need to consider what the PR does. Is it even useful? Furthermore, the copyright status of AI-generated code is currently unclear, so the project is not accepting any such submissions at this time. But AI can of course be used as an aid, such as for debugging. Finally, I encourage you to read these documents to familiarize yourself with our project and its practices.
https://docs.freebsd.org/en/books/developers-handbook/ https://docs.freebsd.org/en/articles/problem-reports/