summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--.gitmodules3
-rw-r--r--Makefile2
m---------pwd0
-rw-r--r--pwd.c48
5 files changed, 10 insertions, 44 deletions
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
+Subproject bbfcb397ceaefd5abc3504b85127386cd6a45bd
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 <jakob@kaivo.net>
+ * Copyright (c) 2011-2020, Jakob Kaivo <jakob@kaivo.net>
*
* 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 <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
+#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);
}