Re: [dev] ASCII Delimited Text

2018-05-21 Thread Truls Becken
As an anecdote, I actually wanted to use US/RS delimited text at work
a while ago to consume XML downloaded from some service. The idea was
to use XSLT to convert the data to a sane format that I could easily
ingest. As it turns out, that was a no-can-do because XSL transforms
are defined in an XML dialect, and XML is not allowed to contain ASCII
control characters, not even on escaped form  So you cannot
express this transformation to any of the XSLT engines I tested! I
ended up using a pair of Unicode control chars instead.

-Truls



Re: [dev] securiy guidance

2018-03-06 Thread Truls Becken
Some libraries to look at are; libressl, libtomcrypt, nacl.cr.yp.to,
libsodium, nettle, libgcrypt and libmcrypt.



Re: [dev] securiy guidance

2018-03-05 Thread Truls Becken
Hi Peter,

I know this is not what you asked about, but there is one other thing people
dislike about pass; the file hierarchy is in plain text. If you can fix that,
you might attract some users.

-Truls

On Mon, Mar 5, 2018 at 11:06 AM,   wrote:
> Hello,
>
> this mail won't be related to any suckless projects, I am looking for
> some guidance/tips. If this isn't a good place for such requests I can
> take a hint.
>
> Since I stumbled upon suckless.org (2-3 weeks) I switched to dwm and st,
> read the philosophy and many other pages, browsed through some source
> code, looked up plan 9 in a bit more detail than before, read about 9P,
> the list could go on for a while, you get the idea. I'm not a C
> programmer but decided it's time to try and write something useful.
> Thinking about a good project brought me to password stores. I never
> liked (or trusted) these big fluffy UI-driven password solutions (god
> forbid if they offer cloud syncing and such), so I always sticked with
> pass whenever possible. The only thing I dislike about it is
> piggybacking on gpg, which is big and scary for people who don't use it
> on a daily basis and from my own experience hard to understand and set
> up.
>
> Contemplating on what a pass-like password manager needs to do, making
> it as simple as possible, there's possibly 3 commands needed
> - init - one-time initialization of the password store, key generation,
> ...
> - set  - encrypt a password
> - get  - decrypt a password
>
> The second piece would be a daemon (agent) that caches the master
> password like gpg-agent or ssh-agent does. I don't want to focus on this
> piece until the first one is polished.
>
> Trying my hands on putting this together got me this far:
> https://gitlab.com/xificurC/heslo
>
> If you bore with me this far (pardon for the longer introduction) I can
> finally ask for some guidance: encryption isn't a topic to be taken
> lightly and I wouldn't like to rely on tips from random people on the
> internet. Storing passwords requires 1 encryption/decryption algorithm.
> Which one to choose? I would like to rely on libc only and am naively
> thinking an encryption/decryption algorithm could be easily copied into
> the current source code.
>
> If anyone finds it fun to look through some newcomer-level source code
> to give pointers on what should be changed or pinpoint bugs/issues with
> the code I'd be thrilled.
>
> Thanks in advance and reminding once again - if this is inappropriate
> for this mailing list just say the word. I'm just looking for guidance
> from people who value simplicity and have experience.
>
> --
> 
>   Peter Nagy
> 
>



Re: [dev] [st] mouse usage, right click to plumb selection

2017-09-12 Thread Truls Becken
Plumbing with cwd sounds interesting if it works reliably. I see that
one has to configure
ones shell specifically to output an escape code that the patched ST
will recognize.

Question about the patch itself; why start a shell and construct a
command that involves
cd to change directory? Wouldn't a chdir() in the forked process suck
less? Then exec
plumber_cmd, sel.primary directly. Also the child pid variable seems
unnecessary.



Re: [dev] Linking a directory tree of configuration files

2017-08-31 Thread Truls Becken
On 2017-08-31 09:19, Thomas Levine wrote:
> it would be acceptable to have something like cp -R that differed
> only in that it made hard links instead of copies

This sentence stood out to me because cp already does that with
the -l switch.



Re: [dev] JIT & VM discussion

2016-06-19 Thread Truls Becken
How about QBE, which is one step up from assembly?



Re: [dev] Miscellaneous sbase issues

2015-05-05 Thread Truls Becken
+1 for option 3)

Why would anybody want to trust somebody that creates malicious
archives like that?
A symlink in an archive should just be a symlink, nothing more.

-Truls



[dev] [sbase] [PATCH] cut: clean up file loop

2014-12-17 Thread Truls Becken
---
 cut.c | 18 --
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/cut.c b/cut.c
index aca0083..99ec4ce 100644
--- a/cut.c
+++ b/cut.c
@@ -162,21 +162,19 @@ main(int argc, char *argv[])
 
if (!mode)
usage();
-   if (!argc)
+
+   if (!argc) {
cut(stdin);
-   else {
-   for (; argc--; argv++) {
-   if (strcmp(*argv, -))
-   fp = fopen(*argv, r);
-   else
-   fp = stdin;
-   if (!fp) {
+   } else for (; argc--; argv++) {
+   if (!strcmp(*argv, -)) {
+   cut(stdin);
+   } else {
+   if (!(fp = fopen(*argv, r))) {
weprintf(fopen %s:, *argv);
continue;
}
cut(fp);
-   if (fp != stdin)
-   fclose(fp);
+   fclose(fp);
}
}
return 0;
-- 
1.8.3.1




[dev] [sbase] Why do extra work when the kernel will do it more efficiently?

2014-12-16 Thread Truls Becken
Hi everyone,

As the original contributor of sbase cut, I can't help wondering what the
purpose of the mem freeing added in the two commits from 1st of June is
supposed to be. The most efficient and reliable way to free allocated memory
is to terminate the process. There is no reason to clean things up just to
exit immediately after. Also, the line buffer was reused on purpose, no need
to allocate a new one per file.

-Truls



[dev] Re: [sic] [PATCH] Treat non-option arguments as commands

2014-10-01 Thread Truls Becken
On 2014-10-01, at 01:05, Eric Pruitt wrote:

 I think that still has the same problem mentioned in my other email: the
 remote server may not accept commands until the initial handshake is
 finished.

Sure, but solving that is independent of how you give sic the commands to send.

-Truls


Re: [dev] [sic] [PATCH] Treat non-option arguments as commands

2014-09-30 Thread Truls Becken
Hi,

Did you try something like:

cat ~/.sicrc - | sic

or

cat (echo :j #suckless) - | sic

This should do what you want. The latter example depends on a shell extension,
but process substitution is such a nice idea it should be in all shells, IMHO.

-Truls


[dev] Re: [sic] [PATCH] Classic Suckless config.{def,}.h configurability

2014-09-30 Thread Truls Becken
The patch seems like a good idea.
+1 for %Y-%m-%d as well.

-Truls



Re: [dev] Looking for simple, alpha supporting image format

2014-07-18 Thread Truls Becken
On Fri, Jul 18, 2014 at 7:15 PM, Charlie Murphy cmsmur...@gmail.com wrote:

 Interesting.  How could a header change the compression so much?

How about putting the widthxheight in the file name and having RGBA
data only inside? Would that result in the best possible compression?
Or have a header, but compress the data and not the header ;)

-Truls



[dev] [PATCH] [scron] Log to designated syslog facility

2014-07-06 Thread Truls Becken
---
 crond.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/crond.c b/crond.c
index d416ece..2dbbb76 100644
--- a/crond.c
+++ b/crond.c
@@ -373,7 +373,7 @@ main(int argc, char *argv[])
TAILQ_INIT(ctabhead);
 
if (dflag == 1) {
-   openlog(argv[0], LOG_CONS | LOG_PID, LOG_DAEMON);
+   openlog(argv[0], LOG_CONS | LOG_PID, LOG_CRON);
daemon(0, 0);
}
 
-- 
1.8.4




Re: [dev] C coded lightweight Linux vector graphics editor

2014-06-05 Thread Truls Becken
There is also the pic preprocessor for troff.

-Truls



Re: [dev] lock (1) - a dead simple lock script

2014-04-11 Thread Truls Becken
On 2014-04-08, at 17:48, Calvin Morrison wrote:

 The script will either create the lock and exit, or ping the lock
 every two seconds until the lock is gone (via rmdir).

I'm confused. Surely you also need to lock after old lock goes away?

-Truls



Re: [dev] tmux/screen alternative

2014-02-23 Thread Truls Becken
On 2014-02-23, at 13:13, Raphaël Proust wrote:

 This is very interesting. The main complaint I have towards dtach(1)
 (I have the same complaint about screen(1) and tmux(1), but for those
 it's not the *main* complaint) is the need to first ssh into an
 interactive session. I'd like to do `dtach -a
 user@remote:path-to-session`.


You do not need to ssh into an interactive session.
I use this script, which I call run-screen:

#!/bin/sh
host=$1 # blank means local
cmd=screen -D -R
[ $host ]  cmd=ssh -t $host bash -l -c \$cmd\
exec $cmd




Re: [dev] Announcing sinit - the suckless init

2014-02-15 Thread Truls Becken
Rich Felker included a really minimalistic init in his recent blog post
Broken by design: systemd [1].

-Truls

[1] http://ewontfix.com/14/



Re: [dev] Announcing sinit - the suckless init

2014-02-08 Thread Truls Becken
Hi,

Wrapping the argument to spawn in Arg union is useless now.
Probably a leftover from the design with FIFO.

-Truls



Re: swc library to implement dwm under Wayland (was Re: [dev] gtk3 support for surf?)

2014-01-14 Thread Truls Becken
On 2014-01-14, at 11:42, FRIGN wrote:

 My advice would be to take a look at tinyx[2] and tinyxlib[3], which is
 relatively small and fitting the purpose well (dwm runs on it).
 
 Let's see what the future will bring us, but it now is all about making
 a decision.

I'd like to mention that you don't have to accept xlib to use the X11 protocol.
There is also XCB which is a more direct interface to the protocol, not 
stripping
it for its asynchronous properties.

-Truls


Re: [dev] [sbase] printf(1)

2013-12-19 Thread Truls Becken
On 2013-12-19, at 10:47, FRIGN wrote:

 Considering we have suckless standard libraries like uClibc,
 
 Whoops, I meant dietlibc. I kinda mixed up the names.

musl FTW!

-Truls



Re: [dev] New utility when

2013-12-13 Thread Truls Becken
On 2013-12-13, at 00:48, Samuel Holland wrote:

 And if you only need simple messages, then there's nothing wrong with having 
 to
 quote the on success command:
 
 $ when -t -c xmessage Success command args...
 
 The advantage of specifying the message command as an argument (as opposed to
 ) is that it allows you to pass through the return value of the main 
 command.
 For example, if your long-running program is still running after the timeout,
 you get the message; but it may fail later, and you want to know about that 
 too.
 
 $ when -t -c 'logger Service started successfully' non-forking-service ||
 logger Service exited unexpectedly

This. Not loosing exit code of child process in -t mode is a very good thing.

In -z mode,  -c command  and   command  will be equivalent.

-Truls



Re: [dev] New utility when

2013-12-12 Thread Truls Becken
On 2013-12-12 at 04:54, Andrew Gwozdziewycz wrote:

 On 2013-12-11 at 19:08, Fernando C.V. wrote:
 
 Sounds like a little nice useful utility, even thoguh I don't like
 that the commands have to be passed quoted, as arguments just like
 that. Not sure if there's a much better way to do it, though.
 
 I was thinking about separating commands with ; (I thought about --,
 but lots of commands actually use it) which would of course need to be
 escaped in the same way find(1) ends -exec and friends. However, I've
 used find in the past for just this type of thing, so maybe it's not
 the right choice, but the full command can always just be quoted --
 you'd have to to use pipes anyway, which is certainly common.

There is another way, as hinted at the beginning of the thread.

On 2013-12-11 at 18:15, Dimitris Zervas wrote:

 Instead of passing a second argument, you could return zero and and it in 
 shell
 when command  echo yup! :D

Unless you want when to stay running and finally return the exit code of the
long running process.

If you go this route, when could consume arguments from the beginning of argv,
and then pass the rest of argv to execvp.

Your ssh example becomes:

when -t ssh user@host  xmessage 'Connected'

-Truls


Re: [dev] New utility when

2013-12-12 Thread Truls Becken
On 2013-12-12, at 13:28, Andrew Gwozdziewycz wrote:

 Are you suggesting that the shell handle the command after the ?
 Or you let the subshell I spawn do it?

The shell would handle the command after . The command after recognized
arguments is handled using fork + execvp, without a subshell.

 For the -z mode (default) that could totally work. So, for example:
 
  when cat /file/that/will/eventually/exist  xmessage 'exists'
 
 Instead of running /bin/sh -c 'cat /file/that/will/eventually/exist'
 until the exit status is 0 and then running /bin/sh xmessage
 'exists' you just repeatedly run /bin/sh -c 'cat
 /file/that/will/eventually/exist  xmessage 'exists''

Yes, repeat cat until it succeeds. Then return 0 to the shell.

 I agree that this works, but it's also incorrect because the second
 command must exit with 0, or it'll keep running. I've made the call
 that I don't care about what happens with the second command, only the
 first, and for that reason, that method produces the incorrect
 behavior.

Huh? The when command exits once, letting the shell call xmessage once.

 This doesn't work with -t for the simple reason that if you run
 everything after the when token via '/bin/sh -c ...'  waits for the
 first command to finish, which as stated previously is incorrect.

No. The shell will only let when see the stuff before .

 But, I'm pretty sure you had other intentions, and I'm not following
 your thinking. Could you clarify your point?


In my mind, when would simply:

1) Read all leading elements of argv that start with -.

2) Repeatedly fork and exec argv (which now points to a command and its
   arguments).

3) Return 0 when the child process returns 0, or in the case of -t when the
   child process runs long enough.

The first part is known as chain loading or Bernstein loading, and is done by
programs such as nice, env, sudo, etc. The only issue I see in the context of
when is that the repeated child process will be orphaned in -t mode.

Perhaps my version should be called retry rather than when.

-Truls



Mailing list behaviour - was: [dev] [dmenu] [dwm] [patch] open in new terminal window

2013-11-11 Thread Truls Becken
Please don't reply to a random message in order to start a new thread!

I see people do this from time to time on most of the lists I subscribe to.
Almost never do anybody complain about it, but to me it seems just as bad as
top posting. There is absolutely no reason to do this.

And the irony of this happening to a thread about mailing list behaviour!

-Truls



Re: [dev] [sbase] Command list

2013-10-18 Thread Truls Becken
A few more suggestions:

bc dc dd file find fmt install killall less make sh time which xargs
(un)zip/gzip/bzip2/lzma/xz

Some of these are more complex than others of course.

-Truls



Re: [dev] [sbase] Command list

2013-10-18 Thread Truls Becken
On 2013-10-18, at 12:29, sin wrote:

 find: Useless, just do `du -a | grep blabla'

I'm not interested in disk usage, but finding files based on certain
properties, such as update time, ownership, permissions, etc.

 make: Do we really need this in sbase?

Make is a basic tool, useful in lots of situations.
It would be nice not to rely on GNU for this.

 sh: We agreed to do without a shell.

Yes, and I agree for the user shell. It would still be nice to have a
minimalistic one for scripts, where extensions should be banned anyway.

 xargs: Why?

I use it all the time, most frequently to call less or grep on a list of
files produced by some other command.

-Truls



Re: [dev] [sbase] Command list

2013-10-18 Thread Truls Becken
On 2013-10-18, at 14:53, Strake wrote:

 I'm not interested in disk usage, but finding files based on certain
 properties, such as update time, ownership, permissions, etc.
 
 du -a | cut -f 2

Yes, but how do you filter the result on some combination of file attributes?

du -a | cut -f2 | xargs ls -dl | grep awful pattern | sed 's/.*:[0-9]* //' ?

And then you would have a hard time specifying pattern for newer than 5 days.

If you want to do it this way around, a command is missing for filtering a
list of file names, as already mentioned by Raphaël. It could be generalised
to a command for filtering stdin by calling a predicate command, e.g:

du -a | cut -f2 | filter test -w

For this, test is missing newer than 5 days since that's what find does.

-Truls


Re: [dev] [sbase] Command list

2013-10-18 Thread Truls Becken
On 2013-10-18, at 15:45, Truls Becken wrote:

 If you want to do it this way around, a command is missing for filtering a
 list of file names, as already mentioned by Raphaël. It could be generalised
 to a command for filtering stdin by calling a predicate command, e.g:
 
 du -a | cut -f2 | filter test -w

Just for kicks I wrote filter. With this, the above gives same result as:

find . -perm +222

At least after sorting both outputs, and as long as the fact that these
particular tests do not check the same thing does not bite you. Not sure if it
is useful. It is certainly not standard. As already mentioned, test does not 
provide the same set of tests as find.

-Truls



filter.c
Description: Binary data


Re: [dev] [sbase] [patch] Add primitive du(1)

2013-10-16 Thread Truls Becken
A few trivial comments:

Moving main() to the bottom and usage() to the top would eliminate the 
need to declare them.

Functions push() and pop() seem to only be used once each.  
Would it be too bad to have these few lines directly in the du function?

The switch in du would be slightly simpler as an if statement I think.

Why not use eprintf for the opendir error?

-Truls



[dev] [sbase] [PATCH] Add cut(1)

2013-10-08 Thread Truls Becken
---
LICENSE  |   1 +
Makefile |   1 +
cut.1|  60 +++
cut.c| 164 +++
4 files changed, 226 insertions(+)
create mode 100644 cut.1
create mode 100644 cut.c

diff --git a/LICENSE b/LICENSE
index 927f594..36f0d2c 100644
--- a/LICENSE
+++ b/LICENSE
@@ -14,6 +14,7 @@ MIT/X Consortium License
© 2012 Robert Ransom rransom.8...@gmail.com
© 2013 Jakob Kramer jakob.kra...@gmx.de
© 2013 Anselm R Garbe ans...@garbe.us
+© 2013 Truls Becken truls.bec...@gmail.com

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the Software),
diff --git a/Makefile b/Makefile
index 3c4840d..ce7d95a 100644
--- a/Makefile
+++ b/Makefile
@@ -36,6 +36,7 @@ SRC = \
cmp.c  \
comm.c \
cp.c   \
+   cut.c  \
date.c \
dirname.c  \
echo.c \
diff --git a/cut.1 b/cut.1
new file mode 100644
index 000..0e78ddd
--- /dev/null
+++ b/cut.1
@@ -0,0 +1,60 @@
+.TH CUT 1 sbase\-VERSION
+.SH NAME
+cut \- extract columns of data
+.SH SYNOPSIS
+.B cut \-b
+.I list
+.RB [ \-n ]
+.RI [ file ...]
+.br
+.B cut \-c
+.I list
+.RI [ file ...]
+.br
+.B cut \-f
+.I list
+.RB [ \-d
+.IR delim ]
+.RB [ \-s ]
+.RI [ file ...]
+.SH DESCRIPTION
+.B cut
+out bytes, characters, or delimited fields from each line of the given
+files and write to stdout. With no file, or when file is `-', cut reads
+from stdin.
+.P
+.I list
+is a comma or space separated list of numbers and ranges where numbering
+starts from 1. Ranges are on the form `N-M'. If N or M is missing, the
+beginning or end of line is assumed. Numbers and ranges may be repeated,
+overlapping, and in any order. Selected input is written in the same
+order that it is read, and is written exactly once.
+.SH OPTIONS
+.TP
+.BI \-b \ list
+The
+.I list
+specifies byte positions.
+.TP
+.BI \-c \ list
+The
+.I list
+specifies character positions.
+.TP
+.BI \-d \ delim
+Use first byte of
+.I delim
+as field delimiter, instead of tab.
+.TP
+.BI \-f \ list
+The
+.I list
+specifies field numbers. Lines not containing field delimiters are
+passed through untouched.
+.TP
+.B \-n
+Do not split characters. A character is output if its last byte is
+selected.
+.TP
+.B \-s
+Suppress lines not containing field delimiters.
diff --git a/cut.c b/cut.c
new file mode 100644
index 000..72c20bc
--- /dev/null
+++ b/cut.c
@@ -0,0 +1,164 @@
+/* See LICENSE file for copyright and license details. */
+#include stdbool.h
+#include stdio.h
+#include stdlib.h
+#include string.h
+#include text.h
+#include util.h
+
+static void
+usage(void)
+{
+   eprintf(usage: cut -b list [-n] [file...]\n
+  cut -c list [file...]\n
+  cut -f list [-d delim] [-s] [file...]\n);
+}
+
+typedef struct Range {
+   size_t min, max;
+   struct Range *next;
+} Range;
+
+static Range *list = NULL;
+static char mode = 0;
+static char delim = '\t';
+static bool nflag = false;
+static bool sflag = false;
+
+static void
+insert(Range *r)
+{
+   Range *l, *p, *t;
+
+   for(p = NULL, l = list; l; p = l, l = l-next) {
+   if(r-max  r-max+1  l-min) {
+   r-next = l;
+   break;
+   } else if(!l-max || r-min  l-max+2) {
+   l-min = MIN(r-min, l-min);
+   for(p = l, t = l-next; t; p = t, t = t-next)
+   if(r-max  r-max+1  t-min) break;
+   l-max = (p-max  r-max) ? MAX(p-max, r-max) : 0;
+   l-next = t;
+   return;
+   }
+   }
+   if(p) p-next = r; else list = r;
+}
+
+static void
+parselist(char *str)
+{
+   char *s;
+   size_t n = 1;
+   Range *r;
+
+   for(s = str; *s; s++) {
+   if(*s == ' ') *s = ',';
+   if(*s == ',') n++;
+   }
+   if(!(r = malloc(n * sizeof(Range
+   eprintf(malloc:);
+   for(s = str; n; n--, s++) {
+   r-min = (*s == '-') ? 1 : strtoul(s, s, 10);
+   r-max = (*s == '-') ? strtoul(++s, s, 10) : r-min;
+   r-next = NULL;
+   if(!r-min || (r-max  r-max  r-min) || (*s  *s != ','))
+   eprintf(cut: bad list value\n);
+   insert(r++);
+   }
+}
+
+static size_t
+seek(const char *s, size_t pos, size_t *prev, size_t count)
+{
+   const char *t;
+   size_t n = pos - *prev;
+
+   if(mode == 'b') {
+   if((t = memchr(s, 0, n)))
+   return t - s;
+   if(nflag)
+   while(n  !UTF8_POINT(s[n])) n--;
+   *prev += n;
+   return n;
+   } else if(mode == 'c') {
+   for(n++, t = s; *t; t++)
+   if(UTF8_POINT(*t)  !--n) break;
+   } else {
+   for(t = (count  2) ? s : s+1; n

Re: [dev] [sbase] [patch] Add hostname

2013-08-20 Thread Truls Becken
I guess usage should be eprintf(usage: %s [name]\n, argv0);

Could use puts(buf); instead of printf(%s\n, buf);

-Truls



Re: [dev] surf-0.6-searchengine

2013-08-06 Thread Truls Becken
On 2013-07-31, at 10:40, Ari Malinen wrote:

 I wrote patch which adds search engine integration. If you
 provide url which is not valid then surf passes it to search
 engine. I see this as better approach than the searchengines
 patch from surf.suckless.org.

The advantage of the approach on the wiki is that you can have
multiple search engines configured, or really, URL shortcuts
with optional string substitution. Firefox has the same thing.

Also, there is no heuristic, which means it sucks less.

-Truls



Re: [dev] surf-0.6-searchengine

2013-08-06 Thread Truls Becken
On 2013-08-06, at 21:35, Chris Down wrote:

 On 2013-08-06 21:27, Truls Becken wrote:
 The advantage of the approach on the wiki is that you can have multiple
 search engines configured, or really, URL shortcuts with optional string
 substitution. Firefox has the same thing.
 
 I, for one, only really use one search engine, but I agree that this method is
 inflexible in that way (although that's fairly implicit in the method).


It's not only useful for multiple search engines. You could for instance have
a shortcut for running your default search engine against a specific site,
or as in one of the examples on the wiki, to look up words in a dictionary,
or simply as a shortcut to a page with no argument at all.

-Truls


Re: [dev] [sbase] [patch] Adding tar v2

2013-07-17 Thread Truls Becken
On 2013-07-17, at 15:52, Markus Wichmann wrote:

 Speaking of which, is anyone up for some suckless binutils?

Rob Landley has some vaporware here:

http://landley.net/qcc/

-Truls



Re: [dev] [sbase] [patch] Adding tar v2

2013-07-12 Thread Truls Becken
On 2013-07-12, at 17:30, David Galos wrote:

 The argument parsing is a bit ugly, so simplifications are welcome,
 provided they keep the current functionality

The goto seems uncalled for. An ordinary if does the job equally well.
Also, I wonder if a mode variable isn't just as simple as the flg array.

Proposed patch attached. Is (argc != (mode == 'c')) too clever?

By the way, what is the purpose of strlcpy in xt and unarchive?
Is it in case header fields are not properly zero terminated?



sbase-adding-tar-2.diff.diff
Description: Binary data


Re: [dev] [sbase] Adding tar

2013-07-07 Thread Truls Becken
On 2013-07-07, at 05:53, David Galos wrote:

 If sbase gains programs to do compression, and the code is nicely librarized,
 I will consider thinking about considering adding letting tar do that.

Why not call out to the compression program? Pipes are not patented by shells.
This decouples things so it doesn't matter if the compressors are part of sbase
or not.

 why'd you have to go and mix dashed and non like that?

If you didn't see one of -c, -t, -x then parse non dashed options.

-Truls


Re: [dev] [sbase] Adding tar

2013-07-06 Thread Truls Becken
On 2013-07-06, at 12:15, David Galos wrote:

 In short, how do you fine folks invoke your tar?

My habit relays on compression scheme detection:

tar cf foo.txz ~/stuff
tar xf bar.tbz

-Truls



[dev] [sbase] afgets

2013-07-06 Thread Truls Becken
Greetings.

In afgets() the size variable is never updated, which usually means it is always
zero, in which case it has no purpose at all. I believe it is supposed to be
updated on realloc? This way, calling afgets multiple times with the same
arguments will reuse the space if possible.

Also, the return value is just a dereference of the pointer argument, which is
not very useful. Why not return len instead, so the caller does not have to
use strlen to get the length? All current uses of afgets() only check for a
non-zero return value, which would work equally well if length is returned.

Proposed change attached.

-Truls



afgets.patch
Description: Binary data


Re: [dev] Parentheses

2013-07-04 Thread Truls Becken
On 2013-07-04, at 14:12, Bjartur Thorlacius wrote:

 type = argv[1][0] == 'b' ? S_IFBLK : S_IFCHR;
 type = ((argv[1][0] == 'b') ? S_IFBLK : S_IFCHR)

Yes, David did the commit with parens around the test. Not around the elvis 
operator, though.

-Truls


Re: [dev] [sbase] sponge

2013-06-25 Thread Truls Becken
On 2013-06-25, at 20:39, Calvin Morrison wrote:

 sponge sucks up stdin, waits till it is closed then puts it out to stdout

Except it does not actually sponge in the stdout case, only when writing to
file. Perhaps it would be better to drop support for stdout? Or cat temp
file to stdout at the end? Why does it open a temp file when not using it?

From a manpage found somewhere on the net:

  It also creates the output file atomically by renaming a temp file into
  place,  and  preserves the permissions of the output file if it already
  exists.  If the output file is a special file or symlink, the data will
  be written to it.

The two last bits are not so in the proposed sbase version. Should they be?

-Truls


Re: [dev] mail clients

2013-06-11 Thread Truls Becken
On 2013-06-10, at 21:35, Edgaras wrote:

 Also Christop/__20h__ is working on some mail client that sounded quite nice
 and interesting from the description, but afaik it is not yet available(?).

I've heard Christoph mention this, but never seen a description.
Do you have a link?

-Truls


Re: [dev] Re: Why HTTP is so bad?

2013-05-27 Thread Truls Becken
On 2013-05-27, at 12:12, Fernando C.V. wrote:

 Either that or you will need a video player that speaks http.

Which they usually do. It's called streaming and has been popular for roughly 
15 years.

-Truls


Re: [dev] diffdisplays

2013-05-01 Thread Truls Becken
In addition to what Carlos said about using damage evens and transparent 
overlays, you probably want some sort of notification of activity in windows 
not currently displayed on screen. This is similar to urgency wm hints, but 
triggered by window content change rather than explicit application requests. 
One approach is simply to set the urgency hint when change is detected.

Note that this is different from indicating what has changed between two points 
in time as in the image diff suggestion.

One way to use this technology is to dim all windows except the focused one, 
and then change opacity of parts with activity. More in line with the research 
article would be to only dim windows on non-focused monitors.

-Truls


Re: [dev] rio for linux

2013-05-01 Thread Truls Becken
On 2013-05-01, at 07:30, Sam Watkins wrote:

 I don't love X11, and I'm wondering if anyone has ported or made anything
 in the sprit of rio / 9wm to run on top of Linux framebuffer.

Port drawterm to run on fb rather than x11? Then you can run the actual plan 9 
desktop by
connecting to a 9vx process or something? Other ideas are to make 9vx's console 
itself
run on fb, or similar for hosted inferno. Somebody probably did one of these 
already.

http://www.google.com/search?q=(plan9+OR+9vx+OR+drawterm+OR+inferno)+linux+framebuffer

-Truls


Re: [dev] [PATCH] dmenu_run: Don't leave a shell running

2013-04-16 Thread Truls Becken
On 2013-04-16, at 10:17, Ross Lagerwall wrote:

 -dmenu_path | dmenu $@ | ${SHELL:-/bin/sh} 
 +exec $(dmenu_path | dmenu $@)

On 2013-04-16, at 15:47, Ross Lagerwall wrote:

 -dmenu_path | dmenu $@ | ${SHELL:-/bin/sh} 
 +eval exec $(dmenu_path | dmenu $@)

To not screw up the argument passing, you could just have dropped the quotes 
around $(), as in:

exec $(dmenu_path | dmenu $@)

-Truls


Re: [dev] [ANNOUNCE] stem-0.1

2013-04-08 Thread Truls Becken
On 2013-04-08, at 09:22, Christian Hesse wrote:

 I just wanted to build a package for my distribution when I noticed there
 already was a package named stem. It's a python controller library for Tor:
 https://stem.torproject.org/
 
 Looks like I have to choose another name for your script...

You probably only need to name the package differently, not the script itself.
My guess is that the python library does not include an executable named stem.

-Truls


Re: [dev] Find window with dmenu

2013-02-12 Thread Truls Becken
On 2013-02-12, at 13:22, Chris Down wrote:

 Considering he's already doing rudimentary filtering through in *addition*
 to sed calls, awk is more generalisable choice to the problem set.

Alternatively, you could say that sed is the more generalisable choice since
grep is pretty much a subset of sed.

sed -E 's/\s\+// ; /(vim|surf):/d'

-Truls



[dev] Re: [9base][awk] printf and utf-8

2013-01-22 Thread Truls Becken
On 2013-01-22, at 09:05, mauro tonon wrote:

 Also, awk can't know beforehand if the input string is UTF-8 encoded
 or not, so the only thing it can do is to count bytes

Or take the Plan 9 approach of always assuming UTF-8.

-Truls



Re: [dev] Starch has a web site

2012-12-06 Thread Truls Becken
On 2012-12-06, at 05:15, Strake wrote:

 Starch Linux has its own web site now: http://starchlinux.org
 so further announcements will be made there.

Where should discussions take place?
The home page does not mention any community links.

The installation guideline suggests using the Arch installer. That's fine, but
I'd just like to mention that I always found it fascinating how you can install
Arch by booting any Linux system you have at hand (an existing installation or
some live cd), download a static build of pacman, mount the partition you want
to install on, and simply run; ./pacman -S base -r /mnt

All the best with this new distro.

-Truls


Re: [dev] I'm back

2012-11-25 Thread Truls Becken
On 2012-11-25, at 16:39, Noah Birnel wrote:

 I use dwm to manage 10-15 simultaneous RDP sessions. Since RDP eats all
 keystrokes, the mouse is the only way to switch between them.  No mouse = I
 need a different WM.

Assuming you are using rdesktop as RDP client, try option -K to allow window 
manager keys to work.

-Truls


Re: [dev] I'm back

2012-11-21 Thread Truls Becken
Borders are not drawn by dwm, the border width is a part of the window 
configuration dwm tells
the X server to use on each window. The *only* drawing performed by dwm is the 
bar. Getting rid
of the bar would also mean that the status string does not have to pass through 
dwm as it would
rather be piped directly to the bar. dwm would only really need to output tag 
info to stdout.

-Truls


Re: [dev] [announce] rat - ridiculously abysmal tar

2012-11-06 Thread Truls Becken
On 2012-11-06, at 12:00, Andreas Krennmair wrote:

 It currently supports the tar operations c, t and x (which makes it a bit 
 more useful than sltar) and the options -f, -C, -v, -z and -j (for 
 decompression only).

Cool. Did you consider auto detecting compression from file name and/or content?

(Because lazyness is good, and I've grown accustomed to; tar cf stuff.tbz 
~/stuff)

-Truls


Re: [dev] Build system: redo

2012-08-02 Thread Truls Becken
On 2012-08-02, at 00:15, pancake wrote:

 Tup is cool but i find it quite bloated to depend on sqlite. And requires to 
 rebuild the cache for every new file.
 
 Apart from that the rules looks good and graph theory makes the papers cool.

I have not tried Tup, but the idea of tracking dependencies by monitoring which 
files are actually used by commands sounds interesting, although it is a bit of 
a hack.

I'm wondering one thing, however; doesn't this make the build accidentally 
depend on quite irrelevant things such as shell profiles?

-Truls


Re: [dev] [ii] exposed password on process monitoring

2012-04-20 Thread Truls Becken
On 2012-04-19, at 23:03, Kurt H Maier wrote:

 On Thu, Apr 19, 2012 at 10:27:04PM +0200, Truls Becken wrote:
 
 So for the user they seem to have the same effect.
 Perhaps 2) is partly the reason they do 1), by the way.
 
 Let's not make the fantastically naive mistake of assuming this userbase
 is sufficiently large to comprise a statistical universe, much less
 begin throwing pompous shit about the user into this discussion.

I was thinking of IRC users in general.

 You have absolutely no proof that such servers are the most popular
 and no reason to claim shitty server-specific behavior is any reason to
 start crapping all over things defined in an actual RFC.   

Granted, although there is a list somewhere of the 4-5 most popular networks.

Anyway, thanks for clearing this up for those of us that did not fully 
understand the relation between the two kinds of authorisation.

I conclude that I have no current need for PASS, but that's just because it is 
not required by any server I use at the moment.

-Truls


Re: [dev] [ii] exposed password on process monitoring

2012-04-19 Thread Truls Becken
On 2012-04-19, at 17:54, Ivan Kanakarakis wrote:

 I guess some possible workarounds would be
 - reading the passwd from an environmental var (is that any safer?)
 - reading the passwd from a file (overkill ?)
 - ?
 
 what do you people think ?
 should this be 'fixed' in ii ?

$ ii 
$ cat ~/irc/freenode_login_script  ~/irc/irc.freenode.net/in

No need for the program to implement password support at all really.
Perhaps ii would suck less if this was just removed?

 Mind, the password is sent in the clear, so anyone on the same network
 segment, or otherwise in the way, can read it anyhow.
 
 true, does the ssl patch provide any encryption for that ?

Yes.

-Truls



Re: [dev] [ii] exposed password on process monitoring

2012-04-19 Thread Truls Becken
On Thu, Apr 19, 2012 at 20:05, Ivan Kanakarakis wrote:

 I think PASS is good, having it removed wouldn't really gain
 us much, nothing important in terms of loc and would have
 to replace that functionality, that the irc protocol provides
 with a delayed /j nickserv identify ... message.
 which one is cleaner ?

True, PASS is cleaner because of the delay necessary with the nickserv
message. Key as argument sucks quite a bit, though.

-Truls



Re: [dev] [ii] exposed password on process monitoring

2012-04-19 Thread Truls Becken
On Thu, Apr 19, 2012 at 21:21, Kurt H Maier wrote:

 PASS has nothing to do with nickserv.
 nickserv has nothing to do with PASS.

 any server that uses data from the PASS string to do shit with nickserv
 is doing that on its own.

 Why is this not filtering into anyone's skull?

Because:

1) as you mentioned, some servers such as freenode auto-identify with
nickserv if you send PASS
2) the most popular servers do not require PASS to connect

So for the user they seem to have the same effect.
Perhaps 2) is partly the reason they do 1), by the way.

-Truls



Re: [dev] situ — change files in situ

2012-04-13 Thread Truls Becken
There is also sponge from http://kitenet.net/~joey/code/moreutils/

-Truls



Re: [dev] situ — change files in situ

2012-04-13 Thread Truls Becken
On Fri, Apr 13, 2012 at 19:50, Strake wrote:

 There is also sponge from http://kitenet.net/~joey/code/moreutils/

 which would also corrupt file on failure, by what little documentation
 I can read through the markup.

You are right. I thought that since it only opens the output file
after stdin is fully consumed, it would not touch the file on failure.
The test below reveals that sponge leaves the file alone if the
process is interrupted before end of stdin, but not if a program
before it in the pipe returns non-zero.

I guess I should test programs before suggesting them to others.

-Truls

$ echo TEST  tst
$ (sed s/ES/se tst; sleep 10) | sponge tst
sed: -e expression #1, char 7: unterminated `s' command
^C
$ cat tst
TEST
$ sed s/ES/se tst | sponge tst
sed: -e expression #1, char 7: unterminated `s' command
$ wc tst
0 0 0 tst
$



Re: [dev] [surf] [patch] Close stdout after printing XID

2012-02-18 Thread Truls Becken
On Sat, Feb 18, 2012 at 14:50, Abby Cedar wrote:

 Need to close stdout otherwise it can't be used in a script until surf 
 finishes.

 To test, try the below before and after the patch.

 xid=`surf -x `; echo $xid

You are right. The following works around the problem, but is not very elegant;

xid=`surf -x | sed 1q `; echo $xid

-Truls



Re: [dev] sbase TODO patch

2012-02-10 Thread Truls Becken
On 2012-02-09, at 23:52, Connor Lane Smith wrote:

 const char *s = (argc  2) ? y : argv[1];
 while(puts(s) != EOF);

On 2012-02-10, at 10:12, clamiax wrote:

 http://cvsweb.netbsd.org/bsdweb.cgi/src/usr.bin/yes/yes.c?rev=1.8.22.1content-type=text/x-cvsweb-markup


How about:

#include stdio.h

int
main(int argc, char **argv)
{
const char *s = (argc  1) ? argv[1] : y;
while(puts(s) != EOF);

return 1;
}




Re: [dev] dwm rules do not check window's first class

2012-01-02 Thread Truls Becken
On 2012-01-02, at 09:34, James Campos wrote:

 I added a rule to place windows of a certain class to a certain
 tag. However, windows apparently have two classes, and this rule
 only works if it specifies the second class.

I believe what you are looking for is the second Rule field, the
one called instance. This is checked against the first part of
the class reported by xprop.

-Truls



Re: [dev] xv6

2011-11-12 Thread Truls Becken
In my defence, I both searched through the mailing list page using my
browser, and searched for xv6 site:suckless.org with DDG, without
finding anything. After Kurt pointed out that it had been discussed
before, I tried the same query with Google, which found one mail
mentioning xv6 in the middle of a thread about games.

Note to self; Google still works better than DuckDuckGo.



Re: [dev] Compilers

2011-11-12 Thread Truls Becken
On Sat, Nov 12, 2011 at 17:33, Bjartur Thorlacius wrote:

 Clang (cool, but bytecode)

What do you mean? Yes, LLVM uses what it calls bitcode as part of the
process, but the final result is a native binary.

-Truls



[dev] xv6

2011-11-09 Thread Truls Becken
Hi,

Professors at MIT have rewritten Unix V6 in 7000 lines of ANSI C for use in
operating system class. I thought it might interest some people on this list.

http://pdos.csail.mit.edu/6.828/2011/xv6.html

-Truls