Herbert Xu | 2 May 2009 04:01
Picon
Picon

Re: Dash problem with IFS

On Fri, May 01, 2009 at 11:33:08AM -0700, Haibo Xu wrote:
>
> > #!/bin/sh
> >
> > IFS=$' \t\n'

IFS is not supposed to interpret escape sequences.  Quoting POSIX

1419               IFS                   (Input Field Separators.) A string treated as a list of characters that is used for
1420                                     field splitting and to split lines into fields with the read command. If IFS is not
1421                                     set, the shell shall behave as if the value of IFS is <space>, <tab>, and
1422                                     <newline>; see Section 2.6.5 (on page 2244). Implementations may ignore the |
1423                                     value of IFS in the environment at the time the shell is invoked, treating IFS as |
1424                                     if it were not set.                                                                    |

So if you want it to have a tab and newline you need to specify
them literally, or use something that does interpret escapes,
like

IFS=$(echo '\n\t $')

Cheers,
--

-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert <at> gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majordomo <at> vger.kernel.org
(Continue reading)

Haibo Xu | 2 May 2009 06:31
Picon

Re: Dash problem with IFS

Thanks for the explanation, but the quoted text does not mention
whether IFS is or is not supposed to interpret escape sequence. If IFS
is a string of characters, I guess most people will regard string
"\t\n" as a two character string, the first one being <tab>, and the
2nd one being the <newline>.

On Fri, May 1, 2009 at 7:01 PM, Herbert Xu <herbert <at> gondor.apana.org.au> wrote:
> On Fri, May 01, 2009 at 11:33:08AM -0700, Haibo Xu wrote:
>>
>> > #!/bin/sh
>> >
>> > IFS=$' \t\n'
>
> IFS is not supposed to interpret escape sequences.  Quoting POSIX
>
> 1419               IFS                   (Input Field Separators.) A string treated as a list of
characters that is used for
> 1420                                     field splitting and to split lines into fields with the
read command. If IFS is not
> 1421                                     set, the shell shall behave as if the value of IFS is
<space>, <tab>, and
> 1422                                     <newline>; see Section 2.6.5 (on page 2244).
Implementations may ignore the |
> 1423                                     value of IFS in the environment at the time the shell is
invoked, treating IFS as |
> 1424                                     if it were not set.                                  
                                 |
>
> So if you want it to have a tab and newline you need to specify
> them literally, or use something that does interpret escapes,
(Continue reading)

Oleg Verych | 7 May 2009 18:01
Picon
Gravatar

Re: Dash problem with IFS

>  So if you want it to have a tab and newline you need to specify
>  them literally, or use something that does interpret escapes,
>  like

newline and tab, because in output substitution trailing '\n's
(default in any `echo`) are removed.

>  IFS=$(echo '\n\t $')

`echo` isn't a good example due to historical feature-support problems, imho.

# newline and tab
IFS=`printf '\n\t'`
# just newline
IFS=`printf '\n+'`; IFS=${IFS%+}

last example is POSIXly correct ugliness. Bashizm looks better (:

IFS=$'\n'

where $' ' is one, not "\t is <tab> in $IFS", guys.
--

-- 
sed 'sed && sh + olecom = love'  <<  ''
-o--=O`C
 #oo'L O
<___=E M
--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
(Continue reading)

Sven Mascheck | 11 May 2009 15:48
Picon

Re: Dash problem with IFS

On Thu, May 07, 2009 at 07:01:56PM +0300, Oleg Verych wrote:

> # just newline
> IFS=`printf '\n+'`; IFS=${IFS%+}

> last example is POSIXly correct ugliness. Bashizm looks better (:
> 
> IFS=$'\n'

PS: I see the problem distinguishing a tab from a space,
but everything but a literal newline is bloat

IFS='
'
--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Oleg Verych | 11 May 2009 21:31
Picon
Gravatar

Re: Dash problem with IFS

On 5/11/09, Sven Mascheck:
> On Thu, May 07, 2009 at 07:01:56PM +0300, Oleg Verych wrote:
>
>  > # just newline
>  > IFS=`printf '\n+'`; IFS=${IFS%+}
>
>  > last example is POSIXly correct ugliness. Bashizm looks better (:
>  >
>  > IFS=$'\n'
>
>
> PS: I see the problem distinguishing a tab from a space,
>  but everything but a literal newline is bloat

Old plain WYSIWYG :)

>  IFS='
>
> '

but this is something, that doesn't look like one new line... (e-mail
or web text encodings/filters?)
--

-- 
sed 'sed && sh + olecom = love'  <<  ''
-o--=O`C
 #oo'L O
<___=E M
--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majordomo <at> vger.kernel.org
(Continue reading)

Oleg Verych | 12 May 2009 23:15
Picon
Gravatar

Re: Dash problem with IFS

On 5/11/09, Oleg Verych <olecom <at> gmail.com> wrote:
>  >  IFS='
>  >
>  > '
>
>  but this is something, that doesn't look like one new line... (e-mail
>  or web text encodings/filters?)

yes, this is web.gmail glasses, sorry.

--

-- 
sed 'sed && sh + olecom = love'  <<  ''
-o--=O`C
 #oo'L O
<___=E M
--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Eitan Adler | 22 May 2009 16:06
Picon

dash build errors

When I try to compile dash on FreeBSD 7.2-STABLE i386
I get the following:

$gmake
gmake  all-recursive
gmake[1]: Entering directory `/home/variable/dash-0.5.1'
Making all in src
gmake[2]: Entering directory `/home/variable/dash-0.5.1/src'
gmake  all-am
gmake[3]: Entering directory `/home/variable/dash-0.5.1/src'
if gcc -DBSD=1 -DSMALL -DSHELL -DGLOB_BROKEN -DFNMATCH_BROKEN
-DIFS_BROKEN -D__COPYRIGHT\(x\)= -D__RCSID\(x\)= -D_DIAGASSERT\(x\)= -I.
-I. -I..  -include ../config.h   -g -O2 -Wall -MT exec.o -MD -MP -MF
".deps/exec.Tpo" \
          -c -o exec.o `test -f 'exec.c' || echo './'`exec.c; \
        then mv -f ".deps/exec.Tpo" ".deps/exec.Po"; \
        else rm -f ".deps/exec.Tpo"; exit 1; \
        fi
exec.c: In function 'find_command':
exec.c:317: error: storage size of 'statb' isn't known
exec.c:326: warning: implicit declaration of function 'stat64'
exec.c:317: warning: unused variable 'statb'
gmake[3]: *** [exec.o] Error 1
gmake[3]: Leaving directory `/home/variable/dash-0.5.1/src'
gmake[2]: *** [all] Error 2
gmake[2]: Leaving directory `/home/variable/dash-0.5.1/src'
gmake[1]: *** [all-recursive] Error 1
gmake[1]: Leaving directory `/home/variable/dash-0.5.1'
gmake: *** [all] Error 2

(Continue reading)

Herbert Xu | 23 May 2009 04:23
Picon
Picon

Re: [JOBS] Do not close stderr when /dev/tty fails to open

On Sun, Feb 22, 2009 at 07:33:04PM +0800, Herbert Xu wrote:
> [JOBS] Do not close stderr when /dev/tty fails to open

Turns out that there was more to this than jobs.c  The use of
savefd in redir ended up closing the wrong file descriptor too,
albeit in a harmless manner.  I'm going to throw this fix in.

commit 3db215abfe4c0079cc932d7070ad675e5f6273ea
Author: Herbert Xu <herbert <at> gondor.apana.org.au>
Date:   Sat May 23 12:21:26 2009 +1000

    [REDIR] Fix incorrect savefd conversions

    When I added savefd we ended up closing the wrong fd in two of
    the three places where it was used.  This is because we often
    want to close an fd other than the one that was dupped.  This
    patch fixes this by adding a second argument to savefd denoting
    the fd to be closed.

    Signed-off-by: Herbert Xu <herbert <at> gondor.apana.org.au>

diff --git a/src/input.c b/src/input.c
index 27c4fd1..1e198e9 100644
--- a/src/input.c
+++ b/src/input.c
 <at>  <at>  -410,7 +410,7  <at>  <at>  setinputfile(const char *fname, int flags)
 		sh_error("Can't open %s", fname);
 	}
 	if (fd < 10)
-		fd = savefd(fd);
(Continue reading)

Nikola Vladov | 24 May 2009 09:59
Picon
Favicon

memalloc.c patch

Hi!  I find some never used code and removed it!

XXXSIZE is for systems which have malloc that uses
mmap/munmap for big blocks.  The patch forces
stalloc to malloc XXXSIZE block after first call of stalloc.
Az a result first stalloc starts with MINSIZE and next
with XXXSIZE.  On my system dash malloc 512 bytes first time.

If some command is too big it grows the stck many times with
4096 bytes by need.  After the command finish it munmap all
unneeded pages.

Nikola

diff -urN dash-0.5.5.1/src/memalloc.c dash-0.5.5.1_nv/src/memalloc.c
--- dash-0.5.5.1/src/memalloc.c	Wed Jan 14 01:37:13 2009
+++ dash-0.5.5.1_nv/src/memalloc.c	Sun May 24 10:32:15 2009
 <at>  <at>  -97,18 +97,24  <at>  <at> 
  */

 /* minimum size of a block */
-#define MINSIZE SHELL_ALIGN(504)
+/* #define MINSIZE SHELL_ALIGN(504) */
+typedef struct { void *next; size_t size; } __alloc_t;
+#define MINSIZE (512  -SHELL_ALIGN(sizeof(void*) + sizeof(__alloc_t)))
+
+#if defined(__dietlibc__) || defined(MALLOC_USES_MMAP_FOR_BIG_BLOCKS)
+#include <sys/shm.h>	/* PAGE_SIZE */
+#define XXXSIZE (PAGE_SIZE -SHELL_ALIGN(sizeof(void*) + sizeof(__alloc_t)))
+#endif
(Continue reading)

Alexey Gladkov | 25 May 2009 12:51
Picon

[PATCH] Fix gcc 4.4 string literal problem

Signed-off-by: Alexey Gladkov <gladkov.alexey <at> gmail.com> 
--- 
 src/jobs.c |    2 +- 
 1 files changed, 1 insertions(+), 1 deletions(-) 

diff --git a/src/jobs.c b/src/jobs.c 
index b1ab7ab..305189e 100644 
--- a/src/jobs.c 
+++ b/src/jobs.c 
 <at>  <at>  -427,7 +427,7  <at>  <at>  sprint_status(char *s, int status, int sigonly) 
                                goto out; 
 #endif 
                } 
-               col = fmtstr(s, 32, strsignal(st)); 
+               col = fmtstr(s, 32, "%s", strsignal(st)); 
                if (WCOREDUMP(status)) { 
                        col += fmtstr(s + col, 16, " (core dumped)"); 
                } 
--  
1.6.3.1

--
To unsubscribe from this list: send the line "unsubscribe dash" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Gmane