mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 05:25:32 +03:00
ln: Make the 'path' argument optional
If 'path' is omitted, we create a link with the basename of whatever the target is. This matches what other systems do.
This commit is contained in:
parent
3d7b8de64f
commit
56701f91f9
Notes:
sideshowbarker
2024-07-19 00:47:18 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/56701f91f90
@ -24,6 +24,7 @@
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
@ -44,9 +45,15 @@ int main(int argc, char** argv)
|
||||
Core::ArgsParser args_parser;
|
||||
args_parser.add_option(symbolic, "Create a symlink", "symbolic", 's');
|
||||
args_parser.add_positional_argument(target, "Link target", "target");
|
||||
args_parser.add_positional_argument(path, "Link path", "path");
|
||||
args_parser.add_positional_argument(path, "Link path", "path", Core::ArgsParser::Required::No);
|
||||
args_parser.parse(argc, argv);
|
||||
|
||||
String path_buffer;
|
||||
if (!path) {
|
||||
path_buffer = LexicalPath(target).basename();
|
||||
path = path_buffer.characters();
|
||||
}
|
||||
|
||||
if (symbolic) {
|
||||
int rc = symlink(target, path);
|
||||
if (rc < 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user