From d905faaa0a3180e20532eff6b1effbec06431d87 Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Tue, 6 Oct 2020 17:08:26 -0400 Subject: split pwd into its own repo --- .gitignore | 1 - .gitmodules | 3 +++ Makefile | 2 +- pwd | 1 + pwd.c | 48 ++++++------------------------------------------ 5 files changed, 11 insertions(+), 44 deletions(-) create mode 160000 pwd diff --git a/.gitignore b/.gitignore index 3480f40..fedb0b7 100644 --- a/.gitignore +++ b/.gitignore @@ -11,7 +11,6 @@ fg getopts jobs newgrp -pwd read sh ulimit diff --git a/.gitmodules b/.gitmodules index 9fad81f..00d808e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -8,3 +8,6 @@ [submodule "true"] path = true url = ../true/ +[submodule "pwd"] + path = pwd + url = ../pwd/ diff --git a/Makefile b/Makefile index d0c7662..15c92ea 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,7 @@ OBJECTS=alias.o bg.o builtins.o cd.o command.o fc.o fg.o getopts.o \ unset.o \ interactive.o parse.o init.o getopt.o \ sh.tab.o sh.yy.o -BUILTINS=alias bg cd command fc fg getopts jobs newgrp pwd read \ +BUILTINS=alias bg cd command fc fg getopts jobs newgrp read \ ulimit umask unalias wait all: $(UTILITY) $(L10N) $(BUILTINS) diff --git a/pwd b/pwd new file mode 160000 index 0000000..bbfcb39 --- /dev/null +++ b/pwd @@ -0,0 +1 @@ +Subproject commit bbfcb397ceaefd5abc3504b85127386cd6a45bdb diff --git a/pwd.c b/pwd.c index 00e26e2..beb0b19 100644 --- a/pwd.c +++ b/pwd.c @@ -1,7 +1,7 @@ /* * UNG's Not GNU * - * Copyright (c) 2011, Jakob Kaivo + * Copyright (c) 2011-2020, Jakob Kaivo * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -18,47 +18,11 @@ */ #include "sh.h" -#include -#include -#include +#define main real_pwd_main +#include "pwd/pwd.c" -const char *pwd_desc = "return working directory name"; -const char *pwd_inv = "pwd [-L|-P]"; - -int -pwd_main (int argc, char **argv) +int pwd_main(int argc, char *argv[]) { - //char mode = 'L'; - char *cwd; - int c; - - while ((c = getopt (argc, argv, ":LP")) != -1) { - switch (c) { - case 'L': - case 'P': - ////mode = c; - break; - default: - return 1; - } - } - - if (optind < argc) - return 1; - - // FIXME: - // if (mode == 'L') - // if (cwd !~ /./ && cwd !~ /../) - // print (cwd); - // else if (strlen (cwd) > PATH_MAX && NO_DOT_OR_DOT_DOT) - // unspecified - // else - // mode = 'P'; - // if (mode == 'P') - // decompose_to_shortest_path - // print (decomposed) - cwd = (char*)getenv ("PWD"); - printf ("%s\n", cwd); - - return 0; + opterr = 0; + return real_pwd_main(argc, argv); } -- cgit v1.2.1