add pwd, thanks stateless
This commit is contained in:
parent
474ee643ed
commit
687e5411ee
1
LICENSE
1
LICENSE
@ -2,6 +2,7 @@ MIT/X Consortium License
|
||||
|
||||
© 2011 Connor Lane Smith <cls@lubutu.com>
|
||||
© 2011 Kamil Cholewiński <harry666t@gmail.com>
|
||||
© 2011 stateless <stateless@archlinux.us>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
|
2
Makefile
2
Makefile
@ -1,6 +1,6 @@
|
||||
include config.mk
|
||||
|
||||
SRC = basename.c cat.c date.c echo.c false.c grep.c sleep.c tee.c touch.c true.c wc.c
|
||||
SRC = basename.c cat.c date.c echo.c false.c grep.c pwd.c sleep.c tee.c touch.c true.c wc.c
|
||||
OBJ = $(SRC:.c=.o) util.o
|
||||
BIN = $(SRC:.c=)
|
||||
MAN = $(SRC:.c=.1)
|
||||
|
@ -7,7 +7,7 @@ basename \- strip directory from filename
|
||||
.RI [ suffix ]
|
||||
.SH DESCRIPTION
|
||||
.B basename
|
||||
prints to stdout the
|
||||
prints the
|
||||
.I string
|
||||
with any leading directory components, and the
|
||||
.IR suffix ,
|
||||
|
8
pwd.1
Normal file
8
pwd.1
Normal file
@ -0,0 +1,8 @@
|
||||
.TH PWD 1 sbase\-VERSION
|
||||
.SH NAME
|
||||
pwd \- print working directory
|
||||
.SH SYNOPSIS
|
||||
.B pwd
|
||||
.SH DESCRIPTION
|
||||
.B pwd
|
||||
prints the path of the current working directory.
|
22
pwd.c
Normal file
22
pwd.c
Normal file
@ -0,0 +1,22 @@
|
||||
/* See LICENSE file for copyright and license details. */
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include "util.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
char *buf;
|
||||
long size;
|
||||
|
||||
if((size = pathconf(".", _PC_PATH_MAX)) < 0)
|
||||
size = BUFSIZ;
|
||||
if(!(buf = malloc(size)))
|
||||
eprintf("malloc:");
|
||||
if(!getcwd(buf, size))
|
||||
eprintf("getcwd:");
|
||||
|
||||
puts(buf);
|
||||
return EXIT_SUCCESS;
|
||||
}
|
Loading…
Reference in New Issue
Block a user