Commit Graph

1632 Commits

Author SHA1 Message Date
sin
435b7b5d20 Convert leading whitespace to tabs 2015-10-08 16:18:45 +01:00
FRIGN
e51a2e6d2f Use ISO-date-format in manpages
The one specified by mdoc is hard to read for non-native
speakers from countries which read the date day-first (like
Germany, Greece, North-Korea, Swamp,...).
This is also consistent with how we generally specify dates
at suckless.org.
2015-10-08 17:15:08 +02:00
sin
979f3cb844 env: Fix return value if the command could not be found 2015-10-07 16:25:54 +01:00
sin
fb4ca81fe8 Include fcntl.h for open(2)
It was implicitly included via sys/file.h on my system.
2015-10-07 15:21:24 +01:00
sin
acca463813 If multiple modes are supplied to flock(1), the last one wins 2015-10-07 10:27:47 +01:00
sin
9a176e4011 Add flock entry in README 2015-10-07 10:27:47 +01:00
sin
386fa3d2a7 flock: Set default mode for open(2) 2015-10-07 10:27:47 +01:00
sin
2652dcfd6c Initial implementation of flock(1)
Very useful to prevent overlapping cron jobs amongst other things.
2015-10-07 10:27:47 +01:00
sin
23fdd768f0 Prepend "usage: " in usage() 2015-10-04 17:00:47 +01:00
sin
3423752465 Lint is dead - remove unnecessary cast to (void) 2015-10-04 16:49:59 +01:00
Quentin Rameau
0e2f509883 ls: handle character/block files in long format
Although major() and minor() are not POSIX, we don't want to have macros
there so we rely on their implementation by the target system.
2015-10-04 16:45:51 +01:00
sin
f14a896891 Stop defining major()/minor() and makedev()
Rely on what the system provides.  These are not standardized macros
but any relevant UNIX system will provide them.

We can revisit this in the future if something breaks.
2015-10-04 16:39:28 +01:00
FRIGN
ea986ea504 Match \v as escaped character
Thanks Greg for noticing this!
2015-10-02 14:48:21 +01:00
sin
627119df9f Comment out some more entries in getconf.c to make it build on OpenBSD
Uncomment the entries if your system supports them.
2015-10-01 17:17:23 +01:00
FRIGN
05996b997c Add getconf(1)
The logic is simple, it's just a pain in the ass to fill the
data-structures.
Some lines had to be commented out, as glibc/musl apparently
have not fully implemented the mandatory variables for the
2013 corrigendum of POSIX 2008.

Also added a manpage and the necessary entries in README.

I also removed it from the TODO.
2015-10-01 17:17:23 +01:00
FRIGN
98e7e75ec6 Fix last offset output using skip in od(1)
Yeah, if the skipping is longer than the file itself, we need
to take the skip value, not the address.
Also, only print the last newline when we've actually printed
at least 1 address.
2015-09-30 19:44:11 +01:00
FRIGN
8be7c42863 Make strtol() parsing even stricter in parseoffset()
Be strict about what we pass to it and how we handle errors.
The base-check is done by strtol anyway.
Also improve error-reporting.
2015-09-30 19:44:11 +01:00
FRIGN
c514c580ec Print error message when size == 0 in split(1)
instead of just exiting with code 1. This could be confusing.
2015-09-30 19:44:10 +01:00
FRIGN
fe84305649 Check for size == 0 in split(1) 2015-09-30 19:44:10 +01:00
FRIGN
8125e8829d Convert split(1) to parseoffset()
This drops a lot of duplicate code. Also simplify it in other
parts of the main arg-handler.
2015-09-30 19:44:10 +01:00
FRIGN
870a75076d Harden parseoffset() even more
1) Check for NULL.
2) Check for empty strings.
3) Clarify error-messages.
2015-09-30 19:44:10 +01:00
FRIGN
8163451249 Check parseoffset return value in od(1)
Yeah, kinda embarassing. Forgot about that.
2015-09-30 19:44:10 +01:00
FRIGN
fc886aa144 Implement od(1) v-flag
If this flag is not given, od(1) automatically replaces duplicate
adjacent lines with an '*' for each reoccurence.
If this flag is set, thus, no such filtering occurs.

In this case this would mean having to somehow keep the last printed
line in some backbuffer, building the next line and then doing the
necessary comparisons. This basically means that we duplicate the
functionality provided with uniq(1).

So instead of

$ od -t a > dump

you'd rather do

$ od -t a | uniq -f 1 -c > dump

Skipping the first field is necessary, as the addresses obviously differ.

Now, I was thinking hard why this flag even exists. If POSIX mandated
to add the address before the asterisk, so we know the offset of duplicate
occurrences, this would make sense. However, this is not the case.

Using uniq(1) also gives nicer output:
~ $ echo "111111111111111111111111111111111111111111111111" | od -t a -v | uniq -f 1 -c
      3 0000000   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1
      1 0000060  nl
      1 0000061

in comparison to

$ echo "111111111111111111111111111111111111111111111111" | od -t a
0000000   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1
*
0000060  nl
0000061

Before working on od(1), I didn't even know it would filter out
duplicate adjacent lines like that. This is also a matter of
predictability.

Concluding, the v-flag is implicitly set and users urged to just
use the existing tools provided by the system.
I don't think we would break scripts either. Firstly, it's rather
unlikely to have duplicate lines exactly matching the line-length of
od(1). Secondly, even if a script did that specifically, in the worst
case there would be a counting error or something.

Given od(1) is mostly used interactively, we can safely assume this
feature is for the benefit of the users.

Ditch this legacy POSIX crap!
 Please enter the commit message for your changes. Lines starting
2015-09-30 19:44:10 +01:00
FRIGN
f8f2a56852 Add -j and -N to od(1) and update README
With parseoffset(), it's rather trivial to implement POSIX' rather
obscure commandments.
The -j and -N-flags should be ready to go!
2015-09-30 19:44:10 +01:00
FRIGN
64929039e9 Don't forget to scale in parseoffset() 2015-09-30 19:44:10 +01:00
FRIGN
007df69fc5 Add parseoffset()
This is a utility function to allow easy parsing of file or other
offsets, automatically taking in regard suffixes, proper bases and
so on, for instance used in split(1) -b or od -j, -N(1).
Of course, POSIX is very arbitrary when it comes to defining the
parsing rules for different tools.
The main focus here lies on being as flexible and consistent as
possible. One central utility-function handling the parsing makes
this stuff a lot more trivial.
2015-09-30 19:44:10 +01:00
FRIGN
7132473947 Some small changes for od(1)
1) Move usage() down above main().
2) Consistently use printaddress() across the code.
3) Use off_t instead of size_t for file offsets.
2015-09-30 19:44:10 +01:00
FRIGN
365f392d3c Properly handle namedict in od(1)
I added the [127]-index but forgot that this increases the length,
breaking a later check.
2015-09-30 19:44:10 +01:00
FRIGN
0d6d1dc02f Check explicit length in od(1)
If you pass an empty string, the null-char will always match
with strchr()!
2015-09-30 19:44:10 +01:00
FRIGN
d49bce7fc8 Refactor parts of od(1)
It was possible to make some sections of the code shorter.
Also fix a bug where the last printed address was always in hex
rather than depending on the radix chosen.
2015-09-30 19:44:10 +01:00
Greg Reagle
fd0d1e4567 Created od, with improvements suggested by FRIGN 2015-09-30 19:44:10 +01:00
Hiltjo Posthuma
521c3734af ls: fix usage line, add f, n and p flag 2015-09-30 19:44:10 +01:00
Hiltjo Posthuma
aba450fd1a ls: printf("%s", s) -> fputs(s, stdout) 2015-09-30 19:44:10 +01:00
Hiltjo Posthuma
874d131728 ls: LEN(pw|grname) -> sizeof() 2015-09-30 19:44:10 +01:00
Hiltjo Posthuma
53be158979 code-style: whitespace fixes 2015-09-30 19:44:10 +01:00
Evan Gates
51009a9600 use CC for sbase-box, remove LD 2015-09-03 19:17:59 +01:00
FRIGN
93f1fc4614 Remove trailing whitespace inside of ls(1) 2015-08-31 18:10:25 +01:00
Quentin Rameau
365e1a324a ls: group sorting options
tflag and Sflag are now grouped under 'sort' var, as suggested by cls.
r-flag handling has been moved inside entcmp().
2015-08-31 18:10:25 +01:00
Quentin Rameau
f1bbe6529a ls: detect infinite loop with recursivity
populate an history of visited directories inodes and search it before
recursing
2015-08-31 18:10:25 +01:00
Quentin Rameau
74b5aa151c ls: correctly handle recursivity
the path is now carried through ls() and lsdir(), directory entries are
listed before recursing.
2015-08-31 18:10:25 +01:00
Quentin Rameau
1905b83cc9 ls: list operands in correct order
sort operands by name, list files first then directory entries
2015-08-31 18:10:25 +01:00
Quentin Rameau
b88ed2ab2d ls: fix -q
Move qflag handling to output() instead of modifying the actual entity
name which broke recursivity.
2015-08-31 18:10:25 +01:00
Wolfgang Corcoran-Mathe
438d2542e4 tail: Don't print garbage when input contains no newlines.
getline(3) expects newline-terminated input. While glibc's
implementation seems to catch unterminated input and zero the
buffer, other versions (notably musl's) do not.

This is a workaround. Garbage will still be read, but
not printed.
2015-08-30 18:36:19 +01:00
sin
1fa942a0ee Add TFTP client as specified by RFC 1350
This client does not support the netascii mode.  The default mode
is octet/binary and should be sufficient.

One thing left to do is to check the source port of the server
to make sure it doesn't change.  If it does, we should ignore the
packet and send an error back without disturbing an existing
transfer.
2015-08-14 13:11:16 +01:00
sin
d6d8c98345 Fix mandoc warnings for sed.1 and find.1 2015-08-14 13:11:16 +01:00
FRIGN
9d429de50d Mark manpages as done in the README for find(1) and sed(1) 2015-08-04 19:46:03 +01:00
Evan Gates
2c0828f3fb add preliminary find(1) manpage 2015-08-04 19:46:03 +01:00
Evan Gates
0bd0c246a5 add preliminary sed(1) manpage 2015-08-04 19:46:03 +01:00
Wolfgang Corcoran-Mathe
ac62259d24 comm: Print first trailing unpaired line in file 1
Previously, a line read from file 1 before a strcmp was
performed would be overwritten and lost. Something like
this:

    comm one_line_file empty_file

produced no output.

This patch is a bit inelegant, but quite simple.
2015-08-04 12:35:44 +01:00
FRIGN
5dc6f3c1e6 Note in the README that find(1) and sed(1) are lacking manpages 2015-08-04 12:08:13 +01:00