Commit Graph

1894 Commits

Author SHA1 Message Date
sin
5dc02f757b Add support for '-' to cat
This chunk will need to be librarified at some point.
2014-07-04 16:52:27 +01:00
sin
a62eda512c Don't require two C-d to exit the loop 2014-07-04 16:52:17 +01:00
sin
f5ac08cc04 Only use /tmp if template is a file and not a path 2014-07-04 16:02:15 +01:00
sin
8eea7f74e9 A plain rm -f is valid and should not be considered an error 2014-07-04 14:55:45 +01:00
sin
75382abbf3 Add some error checking to util/recurse.c
Some more stylistic changes and simplification.
2014-06-30 16:05:51 +01:00
sin
df1b25a187 No need to include unistd.h in echo(1) 2014-06-25 21:27:53 +01:00
Hiltjo Posthuma
696cbdbb68 util.h, mode_t: sys/types.h defines mode_t
see: http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_stat.h.html

this removes the warning with gcc (but musl didn't have this warning).
2014-06-16 23:04:43 +01:00
FRIGN
8f7bc0db35 Refactor rmdir
Use arg.h- and pointer-iterator-idioms.
2014-06-10 11:14:32 +01:00
Tuukka Kataja
612e09af7e Implement -i flag for expand 2014-06-09 17:00:33 +01:00
Tuukka Kataja
6561567597 Fix expand when one of multiple files can't be opened
Currently when multiple files are specified and one of them can't be opened,
expand doesn't correctly skip over the missing file. This patch fixes that.
2014-06-09 17:00:23 +01:00
Tuukka Kataja
8b87d0098a Add unexpand(1) 2014-06-09 17:00:13 +01:00
Jakob Kramer
7f7e7dcbb9 cols: simplify filling with spaces
Use printf("%*s", n, "") instead of allocating
a string filled with spaces.
2014-06-05 11:19:34 +01:00
Jakob Kramer
2e1580ed2d remove unnecessary calls to realloc from tee 2014-06-03 23:46:17 +01:00
Jakob Kramer
7d1fd2621e add -t flag to sort 2014-06-02 13:35:59 +01:00
Hiltjo Posthuma
2ab2d2ee3b remove afgets
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-06-01 18:03:20 +01:00
Hiltjo Posthuma
fab4b384e7 use agetline instead of agets
also use agetline where fgets with a static buffer was used previously.

Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-06-01 18:03:10 +01:00
Hiltjo Posthuma
eac0f658cf check snprintf error aswell, handle as truncation error
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-06-01 18:02:55 +01:00
Hiltjo Posthuma
953ebf3573 code style
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-06-01 18:02:30 +01:00
Hiltjo Posthuma
97ca7c8b6d cut: improvements
- use agetline().
- code style.
- free allocated list.
- don't close stdin if "-" is given.
2014-06-01 18:02:13 +01:00
Hiltjo Posthuma
97fb4a1f9c grep: improvements
improvements:
- improve statuscode behaviour
  - don't exit if a file in a series fails. exit 2 if an error occured
    in a file series. don't exit if there is a read error (like: grep
     input file is a directory).
- use agetline instead of agets().

with the simple test: time seq 1 100000000 | grep 'a'
its 12 seconds (from 24 seconds) on my machine.

Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-06-01 18:02:01 +01:00
Hiltjo Posthuma
d12e953f18 add agetline, separate estrtod to util
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-06-01 18:01:45 +01:00
Hiltjo Posthuma
daad071b31 cut, uudecode: free buf after use
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-06-01 18:01:31 +01:00
Hiltjo Posthuma
2dbb694932 strlcat, strlcpy style
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-06-01 18:01:19 +01:00
sin
07dd658f0d Use -std=c99 by default
Note, the code is largely c89 clean.  This is to avoid certain
warnings on some systems (OSX).
2014-05-31 17:56:34 +01:00
sin
69cde23703 Proper copyright header for strlcpy and strlcat 2014-05-28 11:15:59 +01:00
sin
4896bdf6de Revert "Make grep more memory-efficient"
This reverts commit d9a098ae6bc07188cbaefcd188e5911dec41815d.

Conflicts:
	grep.c

Hiltjo Posthuma <hiltjo@codemadness.org> said:

(Re)compiling the regex for each line doesn't make sense (imho) and
slows it down a lot.

A simple test:

time seq 1 100000000 | grep 'a'

sbase grep (before patch):
    0m22.21s real     0m0.00s user     0m0.00s system

sbase grep (after patch):
    2m16.28s real     0m0.00s user     0m0.00s system

coreutils grep:
    0m1.15s real     0m0.00s user     0m0.00s system

So the patch should be reverted I think.
2014-05-12 12:06:40 +01:00
Hiltjo Posthuma
5b3a0a9382 build warnings: initialise values...
... to make fix gcc warnings with -Wall.

Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
2014-05-12 12:06:14 +01:00
sin
11eef783fe Declare error buffer at start of block 2014-05-12 00:40:29 +01:00
FRIGN
fb1bfe24bb Make grep more memory-efficient 2014-05-12 00:32:50 +01:00
FRIGN
8ea17b2a7d Switching to real name 2014-05-11 11:04:26 +01:00
Jakob Kramer
9366f48b1f sort: simplify linecmp, rename curr => tail 2014-05-06 18:01:44 +01:00
Jakob Kramer
8a44c352ee renice(1): renice is not PASTE 2014-05-06 16:21:56 +01:00
Jakob Kramer
6f7e9a5078 sort: add support for "per-keydef" flags 2014-05-06 16:21:50 +01:00
Jakob Kramer
109e8963f5 sort: ignore trailing newline while sorting 2014-05-06 16:21:45 +01:00
Jakob Kramer
0723c8d32e sort: work with signed integers as well 2014-05-06 16:21:39 +01:00
sin
9694305e05 Chop one level of indentation
eprintf() will exit the program, no need to use the else construct.
2014-05-05 15:12:20 +01:00
sin
b257f7a05f cp: Don't try to open the file twice in case we did not provide -f 2014-05-05 15:06:23 +01:00
sin
02918a46e8 Implement cp -f 2014-05-05 15:02:03 +01:00
Daniel Bainton
c323f6f233 Support reading checksums from stdin 2014-05-05 10:05:48 +01:00
Daniel Bainton
9ad5ca5a15 Add breaks to the sha*sum arg cases 2014-05-05 10:05:43 +01:00
Jakob Kramer
814b04e710 sort: document -b 2014-05-04 00:16:24 +01:00
Jakob Kramer
a2da9edb99 sort: simplify skip_columns 2014-05-04 00:15:57 +01:00
Jakob Kramer
d965985a52 sort: add -b flag; don't use it as default 2014-05-04 00:15:46 +01:00
Jakob Kramer
a62a2197a8 sort: don't evaluate if clause
this fixes that you could specify a key
definition like "-k 1.2.3", which is incorrect.
2014-05-04 00:15:33 +01:00
Jakob Kramer
e535e8d88a sort: replace loop with MIN() 2014-05-04 00:15:23 +01:00
Jakob Kramer
56e1616486 sort: remove 'rest' variable 2014-05-04 00:15:10 +01:00
Jakob Kramer
56b9a26de9 sort: don't repeat skipping columns logic 2014-05-04 00:14:58 +01:00
Jakob Kramer
c4e5354a32 sort: linebuf is no global 2014-05-04 00:14:19 +01:00
sin
f23409f65a Break long line in mktemp(1) 2014-05-02 21:38:40 +01:00
Jakob Kramer
0bc6b1377b sort: readability; check strndup return value 2014-04-30 15:17:01 +01:00