Re: [dev] [sw] Suckless web-framework

From: <crap_AT_wzff.de>
Date: Mon, 5 Apr 2010 01:50:29 +0200

Ugh, HTML-Mail
I'm so not going to read this. Please change your mail client to something sane.

On Mon, Apr 05, 2010 at 12:32:58AM +0200, Paul Malherbe wrote:
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
> <html>
> <head>
> <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
> </head>
> <body text="#000000" bgcolor="#ffffff">
> On 05/04/10 00:02, Uriel wrote:
> <blockquote
> cite="mid:g2m5d375e921004041502xe31f4cby6cfae45b67e185bd_AT_mail.gmail.com"
> type="cite">
> <pre wrap="">I just want to say thanks for reminding me how absolutely hideous sh
> scripts are and to stay away from them.
>
> I honestly can't see why anyone would willfully write anything in sh
> anymore (of course, plain sh is better than using bash, ksh or any
> other horrible extensions of an already awful thing).
>
> uriel
>
>
> On Sun, Apr 4, 2010 at 7:03 PM, <a class="moz-txt-link-rfc2396E" href="mailto:node_AT_lavabit.com">&lt;node_AT_lavabit.com&gt;</a> wrote:
> </pre>
> <blockquote type="cite">
> <blockquote type="cite">
> <blockquote type="cite">
> <pre wrap=""># grep thinks the second argument is a file
> </pre>
> <blockquote type="cite">
> <pre wrap="">BL="^index.md$ ^images$"  # Black list
> </pre>
> </blockquote>
> <pre wrap="">  BL="^index.md$\|^images$" # Black list
> </pre>
> </blockquote>
> <pre wrap="">
> Wrong, take a look at this line:
> BL=`echo ${BL} | sed -e "s/\( \+\|^\)/ -e /g"`
> </pre>
> </blockquote>
> <pre wrap="">
> Yes, -e allows you to do this. However, in the original code you had
> </pre>
> <blockquote type="cite">
> <pre wrap="">BL="^index.md$ ^images$"  # Black list
> </pre>
> </blockquote>
> <pre wrap="">and later...
> </pre>
> <blockquote type="cite">
> <pre wrap="">      for i in `ls ${SITE}/${DIR} | grep -v ${BL}`; do
> </pre>
> </blockquote>
> <pre wrap="">I know the blacklist ($BL) was meant as an example, but if you run this
> code you'll see that grep errors out because it thinks `^images$' is a
> file.
>
> If you really want people to use space as a delimiter, then either do:
>
>  for i in BL; do
>        tmp="$tmp -e $i"
>  done
>  BL=$tmp
>  grep -q $BL
>
> or:
>
>  set -- $BL
>  IFS='|'
>  BL=$*
>  grep -Eq "$BL" ...
>
> Both are pretty stupid.
>
> </pre>
> <blockquote type="cite">
> <blockquote type="cite">
> <pre wrap=""># echo | blah is becoming rampant; let's not ignore it this time
> </pre>
> <blockquote type="cite">
> <pre wrap="">QUERY=`echo ${REQUEST_URI} | sed -e "s,.*${BIN}/*\(.*\),\1,"`
> </pre>
> </blockquote>
> <pre wrap="">  QUERY=`sed "s,.*$BIN/*\(.*\),\1," &lt;&lt;-!
>      $REQUEST_URI
>      !
> </pre>
> </blockquote>
> <pre wrap="">
> So, it is better to use 3 loc for this?
> </pre>
> </blockquote>
> <pre wrap="">
> Sadly, POSIX shell sucks. In bash, perl and powershell you could get
> away with a less verbose herestring:
>
>  grep pattern &lt;&lt;&lt; str
>
> </pre>
> <blockquote type="cite">
> <blockquote type="cite">
> <pre wrap=""># Why heredoc instead of subshell?
> # Compare: time for i in `seq 1 1000`; do echo str | grep pattern
> </pre>
> <blockquote type="cite">
> <pre wrap="">/dev/null; done
> </pre>
> </blockquote>
> <pre wrap=""># ...with: time for i in `seq 1 1000`; do grep pattern &gt;/dev/null &lt;&lt;-!
> #                                    str
> #                                    !
>              # heredocs can also contain subshells... you save one
>              # from `cmd | cmd`
> </pre>
> <blockquote type="cite">
> <pre wrap="">           DIR=`dirname ${QUERY} | sed -e "s,/*$,,"`&gt;
> #                                  done
> </pre>
> </blockquote>
> </blockquote>
> <pre wrap="">
> I see, this is a more interesting argument for using heredocs. But,
> just a question (because I don't really know) is heredocs as standard as
> a plain "echo blah | cmd" ?
> </pre>
> </blockquote>
> <pre wrap="">
> heredocs are defined by POSIX, if that's what you mean by standard
>
>
> Semi unrelated question: why are so many people at suckless using ` `
> instead of $( ) ? I've seen it here, dmenu_path, surf's config.h... etc.
>
> $( ) only fails in very, very old shells... think original bourne
>
>
>
>
>
> </pre>
> </blockquote>
> <pre wrap="">
>
> </pre>
> </blockquote>
> Hi<br>
> <br>
> Again I totally agree with Uriel, rather use a good scripting language
> like python ;-)<br>
> <br>
> <div class="moz-signature">
> <style type="text/css">
> <!--
> P { color: #000000 }
> -->
> </style>
> <p><font face="Helvetica, Arial, sans-serif">Regards </font><br>
> <br>
> <font face="Helvetica, Arial, sans-serif"><font size="4">Paul<br>
> </font></font><font face="Helvetica, Arial, sans-serif"><font
> style="font-size: 8pt;" size="1"></font></font> </p>
> </div>
> <br />--
> <br />This message has been scanned for viruses and
> <br />dangerous content by
> MailScanner, and is
> <br />believed to be clean.
> </body>
> </html>
>
>
Received on Sun Apr 04 2010 - 23:50:29 UTC

This archive was generated by hypermail 2.2.0 : Mon Apr 05 2010 - 00:00:02 UTC