The -d option is a GNU extension and is equivalent to its "-P
--preserve=links" options.
Since we don't implement the --preserve=links functionality anyway (it
means preserve hard links between files), just call it -P, which is
specified by POSIX.
Additionally, there is no need to check for cp_Pf
Otherwise, if the length of the link target is the same as BUFSIZ, we
will try to write past the end of buf.
---
ls.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ls.c b/ls.c
index b48391b..a2fb5cb 100644
--- a/ls.c
+++ b/ls.c
@@ -291,7 +291,7 @@ output(Entry *ent)
Also, implement the -H and -L options.
---
Again, not sure how to handle the long line.
ls.1 | 9 -
ls.c | 32
2 files changed, 28 insertions(+), 13 deletions(-)
diff --git a/ls.1 b/ls.1
index ec61bee..792b07b 100644
--- a/ls.1
+++ b/ls.1
@@ -3,7 +3,7 @@
On Sun, Dec 07, 2014 at 03:43:36PM -0800, Eric Pruitt wrote:
> I don't know if this is the correct behavior. Whether or not a symlink
> to a directory has its contents shown with GNU ls depends on whether or
> not there's a slash present and the flags used:
>
> playground$ mkdir AFolder
>
I don't know if this is the correct behavior. Whether or not a symlink
to a directory has its contents shown with GNU ls depends on whether or
not there's a slash present and the flags used:
playground$ mkdir AFolder
playground$ touch AFolder/Horse
playground$ ln -s AFolder SymbolicLin
---
Not sure if you want to break up the long line. Up to you.
Another possibility is
if (S_ISLINK(ent->mode))
stat(path, &st);
ent->isdir = S_ISDIR(st.st_mode);
which looks nicer, but I'm not sure if stat(2) is required to not modify the st
argument if it fails.
On Sun, Dec 07, 2014 at 10:40:42PM +, Michael Forney wrote:
> ---
> ls.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/ls.c b/ls.c
> index b48391b..90193cc 100644
> --- a/ls.c
> +++ b/ls.c
> @@ -21,6 +21,7 @@ typedef struct {
> off_t size;
> time_t mt
---
ls.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/ls.c b/ls.c
index b48391b..90193cc 100644
--- a/ls.c
+++ b/ls.c
@@ -21,6 +21,7 @@ typedef struct {
off_t size;
time_t mtime;
ino_t ino;
+ int isdir;
} Entry;
static int entcmp(const vo