summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2020-10-06 17:08:26 -0400
committerJakob Kaivo <jkk@ung.org>2020-10-06 17:08:26 -0400
commitd905faaa0a3180e20532eff6b1effbec06431d87 (patch)
treef9feb6435d5b8df27572ed82465abbb327772cee
parent1a3266eed2e91fc0684bee464875773db1040864 (diff)
split pwd into its own repoHEADmaster
-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);
}