From owner-freebsd-standards@FreeBSD.ORG Thu Jul 3 07:30:19 2003 Return-Path: Delivered-To: freebsd-standards@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 08BBC37B401 for ; Thu, 3 Jul 2003 07:30:19 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7F25A43FEC for ; Thu, 3 Jul 2003 07:30:18 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h63EUIUp053168 for ; Thu, 3 Jul 2003 07:30:18 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h63EUHGI053167; Thu, 3 Jul 2003 07:30:17 -0700 (PDT) Date: Thu, 3 Jul 2003 07:30:17 -0700 (PDT) Message-Id: <200307031430.h63EUHGI053167@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org From: Wartan Hachaturow Subject: [patch] Re: standards/52972: /bin/sh arithmetic not POSIX compliant X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Wartan Hachaturow List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Jul 2003 14:30:19 -0000 The following reply was made to PR standards/52972; it has been noted by GNATS. From: Wartan Hachaturow To: Jens Schweikhardt Cc: freebsd-gnats-submit@freebsd.org Subject: [patch] Re: standards/52972: /bin/sh arithmetic not POSIX compliant Date: Thu, 3 Jul 2003 18:27:53 +0400 Hello. I've hacked out a simple patch for 5.1-RELEASE's /bin/sh, implementing variables support in arithmetic evaluation, along with various assignment operators. Since the patch is pretty big (11k), I won't include it right in the letter, it may be grabbed from http://velvet.myxomop.com/~wart/ash.patch Below are some comments to the patch: First of all, arithmetics variables are plain shell variables, without any integer/string variable difference. If the variable doesn't exist, it is initialized to zero, as SUS requires. When integer value is needed, the result of lookupvar() is strtol'ed. Austin group's proposed change to the standart says that the behaviour in case of unconvertable string is unspecified. I try to avoid the case of "1ab" being silently converted to integer 1, and check that. There's one miss, though -- just like bash, we skip initial whitespaces in the variable (inside strtol): $ a=" 1" $ echo $((a+1)) 2 I don't consider this being clever, but I didn't find the way to avoid it (after all, results are unspecified :). Integer to string coversion is performed via snprintf. SUS now requires us to have at least signed long arithmetics. I've tried to make the code type-independent, and introduced an arith_t typedef (is it ok with style(9)?) with the macros for strtoarith_t and atoarith_t. 11 assignment operators are implemented, following SUS requirement. I haven't found a test suite for shell arithmetics, but simple things like $ i=1; j=2; k=3 $ echo $((i+=j+=k)) 6 $ echo $i, $j, $k 6, 5, 3 work so far. If anyone would submit a test suite, I'll be glad to test it. Only decimal-base arithmetics is implemented. Thus, x=010 is being treated as decimal 10. I've browsed SUS, trying to find the requirement for other bases, but haven't found it. Should we support it? Comments, fixes, bugs, blames, etc. are welcome. -- Regards, Wartan. "Computers are not intelligent. They only think they are." From owner-freebsd-standards@FreeBSD.ORG Thu Jul 3 12:50:17 2003 Return-Path: Delivered-To: freebsd-standards@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D2CAF37B401 for ; Thu, 3 Jul 2003 12:50:17 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6D4F943F85 for ; Thu, 3 Jul 2003 12:50:17 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h63JoHUp086730 for ; Thu, 3 Jul 2003 12:50:17 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h63JoGeu086729; Thu, 3 Jul 2003 12:50:16 -0700 (PDT) Date: Thu, 3 Jul 2003 12:50:16 -0700 (PDT) Message-Id: <200307031950.h63JoGeu086729@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org From: Jens Schweikhardt Subject: Re: standards/52972: /bin/sh arithmetic not POSIX compliant X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Jens Schweikhardt List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Jul 2003 19:50:18 -0000 The following reply was made to PR standards/52972; it has been noted by GNATS. From: Jens Schweikhardt To: Wartan Hachaturow Cc: GNATS Bug Followup Subject: Re: standards/52972: /bin/sh arithmetic not POSIX compliant Date: Thu, 3 Jul 2003 21:40:06 +0200 Wartan, On Thu, Jul 03, 2003 at 06:27:53PM +0400, Wartan Hachaturow wrote: # Hello. # # I've hacked out a simple patch for 5.1-RELEASE's /bin/sh, implementing # variables support in arithmetic evaluation, along with various assignment # operators. # # Since the patch is pretty big (11k), I won't include it right in the letter, # it may be grabbed from # http://velvet.myxomop.com/~wart/ash.patch Thanks for taking up the grunt work and implementing this. This is more than I hoped for! I've looked at your patch (not yet applied and tested) and have a few remarks: + It appears this is a patch against RELENG_4; is this true? If yes, a patch against HEAD is needed. + There are many lines with whitespace at end-of-line which you should remove. Can you instruct your editor to make these visible? + Reversing comparisons against constant values like in if (NULL == lookupvar($1)) look like a style(9) violation. PS: 11k is not really a big patch. Nobody would mind if you send your improved patch to the GNATS db. URLs with patches tend to become stale very soon. Regards, Jens -- Jens Schweikhardt http://www.schweikhardt.net/ SIGSIG -- signature too long (core dumped) From owner-freebsd-standards@FreeBSD.ORG Thu Jul 3 13:40:16 2003 Return-Path: Delivered-To: freebsd-standards@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DBFC937B401 for ; Thu, 3 Jul 2003 13:40:16 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 293A143FFD for ; Thu, 3 Jul 2003 13:40:16 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h63KeFUp092899 for ; Thu, 3 Jul 2003 13:40:15 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h63KeFLh092898; Thu, 3 Jul 2003 13:40:15 -0700 (PDT) Date: Thu, 3 Jul 2003 13:40:15 -0700 (PDT) Message-Id: <200307032040.h63KeFLh092898@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org From: Wartan Hachaturow Subject: Re: standards/52972: /bin/sh arithmetic not POSIX compliant X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Wartan Hachaturow List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Jul 2003 20:40:17 -0000 The following reply was made to PR standards/52972; it has been noted by GNATS. From: Wartan Hachaturow To: Jens Schweikhardt Cc: GNATS Bug Followup Subject: Re: standards/52972: /bin/sh arithmetic not POSIX compliant Date: Fri, 4 Jul 2003 00:35:55 +0400 --jRHKVT23PllUwdXP Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Jul 03, 2003 at 09:40:06PM +0200, Jens Schweikhardt wrote: > Thanks for taking up the grunt work and implementing this. This is more > than I hoped for! Someone should have made it :) > + It appears this is a patch against RELENG_4; is this true? If yes, a > patch against HEAD is needed. Well, it was against RELENG_5_1. But the attached one is against HEAD (though it have some remniscents like rcs ids from 5_1). Looks like nothing has changed in ash since 5_1, initial patch applied flawlessly. > + There are many lines with whitespace at end-of-line which you should > remove. Can you instruct your editor to make these visible? Ok, looks like I've removed them now. ":set list" was of a great help :) > + Reversing comparisons against constant values like in > if (NULL == lookupvar($1)) > look like a style(9) violation. I heard somewhere that it's treated as a good habit, and was in process of getting myself used to that kind of comparison (like you may have noticed, I mixed both ways :). But if it's against style(9), I'll drop it. (My internal nature was against it, anyway :). > PS: 11k is not really a big patch. Nobody would mind if you send your > improved patch to the GNATS db. URLs with patches tend to become > stale very soon. Ok, improved one is attached. -- Regards, Wartan. "Computers are not intelligent. They only think they are." --jRHKVT23PllUwdXP Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="ash.patch.2" diff -u ./FreeBSD_ASH_HEAD.orig/arith.h ./FreeBSD_ASH_HEAD/arith.h --- ./FreeBSD_ASH_HEAD.orig/arith.h Fri Jul 4 00:16:21 2003 +++ ./FreeBSD_ASH_HEAD/arith.h Thu Jul 3 23:52:01 2003 @@ -31,8 +31,9 @@ * SUCH DAMAGE. * * @(#)arith.h 1.1 (Berkeley) 5/4/95 - * $FreeBSD: src/bin/sh/arith.h,v 1.6 2002/02/02 06:50:45 imp Exp $ + * $FreeBSD: src/bin/sh/arith.h,v 1.5.2.1 2002/07/19 04:38:51 tjr Exp $ */ +int arith_assign(char *, arith_t); int arith(char *); int expcmd(int , char **); diff -u ./FreeBSD_ASH_HEAD.orig/arith.y ./FreeBSD_ASH_HEAD/arith.y --- ./FreeBSD_ASH_HEAD.orig/arith.y Fri Jul 4 00:16:21 2003 +++ ./FreeBSD_ASH_HEAD/arith.y Fri Jul 4 00:09:27 2003 @@ -1,5 +1,65 @@ -%token ARITH_NUM ARITH_LPAREN ARITH_RPAREN +%{ +/*- + * Copyright (c) 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Kenneth Almquist. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ +#ifndef lint +#if 0 +static char sccsid[] = "@(#)arith.y 8.3 (Berkeley) 5/4/95"; +#endif +static const char rcsid[] = + "$FreeBSD: src/bin/sh/arith.y,v 1.10.2.2 2002/07/19 04:38:51 tjr Exp $"; +#endif /* not lint */ + +#include +#include "shell.h" +#include "var.h" +%} +%union { + arith_t l_value; + char* s_value; +} +%token ARITH_NUM ARITH_LPAREN ARITH_RPAREN +%token ARITH_VAR + +%type expr +%right ARITH_ASSIGN +%right ARITH_ADDASSIGN ARITH_SUBASSIGN +%right ARITH_MULASSIGN ARITH_DIVASSIGN ARITH_REMASSIGN +%right ARITH_RSHASSIGN ARITH_LSHASSIGN +%right ARITH_BANDASSIGN ARITH_BXORASSIGN ARITH_BORASSIGN %left ARITH_OR %left ARITH_AND %left ARITH_BOR @@ -18,7 +78,6 @@ } ; - expr: ARITH_LPAREN expr ARITH_RPAREN = { $$ = $2; } | expr ARITH_OR expr = { $$ = $1 ? $1 : $3 ? $3 : 0; } | expr ARITH_AND expr = { $$ = $1 ? ( $3 ? $3 : 0 ) : 0; } @@ -51,62 +110,139 @@ | ARITH_SUB expr %prec ARITH_UNARYMINUS = { $$ = -($2); } | ARITH_ADD expr %prec ARITH_UNARYPLUS = { $$ = $2; } | ARITH_NUM + | ARITH_VAR { + char *p; + arith_t arith_val; + char *str_val; + + if (lookupvar($1) == NULL) + setvarsafe($1, "0", 0); + str_val = lookupvar($1); + + arith_val = strtoarith_t(str_val, &p, 0); + /* Conversion is successful only + * in case we've converted _all_ characters. + */ + if (strncmp(p, "\0", 1) != 0) + yyerror("variable conversion error"); + $$ = arith_val; + } + | ARITH_VAR ARITH_ASSIGN expr { + if (arith_assign($1, $3) != 1) + yyerror("variable assignment error"); + $$ = $3; + } + | ARITH_VAR ARITH_ADDASSIGN expr { + arith_t value; + + value = atoarith_t(lookupvar($1)) + $3; + if (arith_assign($1, value) != 0) + yyerror("variable assignment error"); + $$ = value; + } + | ARITH_VAR ARITH_SUBASSIGN expr { + arith_t value; + + value = atoarith_t(lookupvar($1)) - $3; + if (arith_assign($1, value) != 0) + yyerror("variable assignment error"); + $$ = value; + } + | ARITH_VAR ARITH_MULASSIGN expr { + arith_t value; + + value = atoarith_t(lookupvar($1)) * $3; + if (arith_assign($1, value) != 0) + yyerror("variable assignment error"); + $$ = value; + } + | ARITH_VAR ARITH_DIVASSIGN expr { + arith_t value; + + if ($3 == 0) + yyerror("division by zero"); + + value = atoarith_t(lookupvar($1)) / $3; + if (arith_assign($1, value) != 0) + yyerror("variable assignment error"); + $$ = value; + } + | ARITH_VAR ARITH_REMASSIGN expr { + arith_t value; + + if ($3 == 0) + yyerror("division by zero"); + + value = atoarith_t(lookupvar($1)) % $3; + if (arith_assign($1, value) != 0) + yyerror("variable assignment error"); + $$ = value; + } + | ARITH_VAR ARITH_RSHASSIGN expr { + arith_t value; + + value = atoarith_t(lookupvar($1)) >> $3; + if (arith_assign($1, value) != 0) + yyerror("variable assignment error"); + $$ = value; + } + | ARITH_VAR ARITH_LSHASSIGN expr { + arith_t value; + + value = atoarith_t(lookupvar($1)) << $3; + if (arith_assign($1, value) != 0) + yyerror("variable assignment error"); + $$ = value; + } + | ARITH_VAR ARITH_BANDASSIGN expr { + arith_t value; + + value = atoarith_t(lookupvar($1)) & $3; + if (arith_assign($1, value) != 0) + yyerror("variable assignment error"); + $$ = value; + } + | ARITH_VAR ARITH_BXORASSIGN expr { + arith_t value; + + value = atoarith_t(lookupvar($1)) ^ $3; + if (arith_assign($1, value) != 0) + yyerror("variable assignment error"); + $$ = value; + } + | ARITH_VAR ARITH_BORASSIGN expr { + arith_t value; + + value = atoarith_t(lookupvar($1)) | $3; + if (arith_assign($1, value) != 0) + yyerror("variable assignment error"); + $$ = value; + } ; %% -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Kenneth Almquist. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef lint -#if 0 -static char sccsid[] = "@(#)arith.y 8.3 (Berkeley) 5/4/95"; -#endif -#endif /* not lint */ -#include -__FBSDID("$FreeBSD: src/bin/sh/arith.y,v 1.14 2003/05/01 16:58:56 obrien Exp $"); - -#include "shell.h" #include "error.h" #include "output.h" #include "memalloc.h" +#define lstrlen(var) (3 + (2 + CHAR_BIT * sizeof((var))) / 3) + char *arith_buf, *arith_startbuf; extern void arith_lex_reset(); int yylex(void); int yyparse(void); + +int +arith_assign(char *name, arith_t value) { + char *str; + int ret; + + str = (char *)ckmalloc(lstrlen(value)); + snprintf(str, sizeof(str), ARITH_FORMAT_STR, value); + ret = setvarsafe(name, str, 0); + free(str); + return ret; +} int arith(char *s) diff -u ./FreeBSD_ASH_HEAD.orig/arith_lex.l ./FreeBSD_ASH_HEAD/arith_lex.l --- ./FreeBSD_ASH_HEAD.orig/arith_lex.l Fri Jul 4 00:16:21 2003 +++ ./FreeBSD_ASH_HEAD/arith_lex.l Fri Jul 4 00:05:44 2003 @@ -39,14 +39,16 @@ #if 0 static char sccsid[] = "@(#)arith_lex.l 8.3 (Berkeley) 5/4/95"; #endif +static const char rcsid[] = + "$FreeBSD: src/bin/sh/arith_lex.l,v 1.14.2.2 2002/07/19 04:38:51 tjr Exp $"; #endif /* not lint */ -#include -__FBSDID("$FreeBSD: src/bin/sh/arith_lex.l,v 1.18 2003/05/01 16:58:56 obrien Exp $"); +#include "shell.h" #include "y.tab.h" #include "error.h" +#include "var.h" +#include "memalloc.h" -extern int yylval; extern char *arith_buf, *arith_startbuf; #undef YY_INPUT #define YY_INPUT(buf,result,max) \ @@ -56,13 +58,25 @@ %% [ \t\n] { ; } -[0-9]+ { yylval = atol(yytext); return(ARITH_NUM); } +[0-9]+ { yylval.l_value = atol(yytext); return(ARITH_NUM); } +[A-Za-z][A-Za-z0-9_]* { + /* If variable doesn't exist, we should + * initialize it to zero + */ + char *temp; + if (lookupvar(yytext) == NULL) + setvarsafe(yytext, "0", 0); + temp = (char *)ckmalloc(strlen(yytext) + 1); + yylval.s_value = strncpy(temp, yytext, sizeof(temp)); + + return(ARITH_VAR); + } "(" { return(ARITH_LPAREN); } ")" { return(ARITH_RPAREN); } "||" { return(ARITH_OR); } "&&" { return(ARITH_AND); } "|" { return(ARITH_BOR); } -"^" { return(ARITH_BXOR); } +"^" { return(ARITH_BXOR); } "&" { return(ARITH_BAND); } "==" { return(ARITH_EQ); } "!=" { return(ARITH_NE); } @@ -79,6 +93,17 @@ "-" { return(ARITH_SUB); } "~" { return(ARITH_BNOT); } "!" { return(ARITH_NOT); } +"=" { return(ARITH_ASSIGN); } +"+=" { return(ARITH_ADDASSIGN); } +"-=" { return(ARITH_SUBASSIGN); } +"*=" { return(ARITH_MULASSIGN); } +"/=" { return(ARITH_DIVASSIGN); } +"%=" { return(ARITH_REMASSIGN); } +">>=" { return(ARITH_RSHASSIGN); } +"<<=" { return(ARITH_LSHASSIGN); } +"&=" { return(ARITH_BANDASSIGN); } +"^=" { return(ARITH_BXORASSIGN); } +"|=" { return(ARITH_BORASSIGN); } . { error("arith: syntax error: \"%s\"\n", arith_startbuf); } %% Common subdirectories: ./FreeBSD_ASH_HEAD.orig/bltin and ./FreeBSD_ASH_HEAD/bltin Common subdirectories: ./FreeBSD_ASH_HEAD.orig/funcs and ./FreeBSD_ASH_HEAD/funcs diff -u ./FreeBSD_ASH_HEAD.orig/shell.h ./FreeBSD_ASH_HEAD/shell.h --- ./FreeBSD_ASH_HEAD.orig/shell.h Fri Jul 4 00:16:21 2003 +++ ./FreeBSD_ASH_HEAD/shell.h Thu Jul 3 23:52:15 2003 @@ -51,6 +51,14 @@ #define JOBS 1 /* #define DEBUG 1 */ +/* Type of used arithmetics. + * SUSv3 requires us to have at least signed long. + */ +typedef long arith_t; +#define strtoarith_t(nptr, endptr, base) strtol(nptr, endptr, base) +#define atoarith_t(arg) atol(arg) +#define ARITH_FORMAT_STR "%ld" + typedef void *pointer; #define STATIC static #define MKINIT /* empty */ --jRHKVT23PllUwdXP-- From owner-freebsd-standards@FreeBSD.ORG Fri Jul 4 13:40:20 2003 Return-Path: Delivered-To: freebsd-standards@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E9CC937B409 for ; Fri, 4 Jul 2003 13:40:19 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id F345A44015 for ; Fri, 4 Jul 2003 13:40:18 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h64KeIUp094769 for ; Fri, 4 Jul 2003 13:40:18 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h64KeI4M094767; Fri, 4 Jul 2003 13:40:18 -0700 (PDT) Date: Fri, 4 Jul 2003 13:40:18 -0700 (PDT) Message-Id: <200307042040.h64KeI4M094767@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org From: Wartan Hachaturow Subject: Re: standards/41576: POSIX compliance of ln(1) X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Wartan Hachaturow List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Jul 2003 20:40:20 -0000 The following reply was made to PR standards/41576; it has been noted by GNATS. From: Wartan Hachaturow To: Lukas Ertl Cc: bug-followup@freebsd.org, tjr@freebsd.org Subject: Re: standards/41576: POSIX compliance of ln(1) Date: Sat, 5 Jul 2003 00:30:46 +0400 > cd /tmp > mkdir foo bar > ln -s foo bla ### now /tmp/bla symlinks to /tmp/foo > ln -sf bar bla ### replace /tmp/bla to point to /tmp/bar, doesn't work FreeBSD is perfectly SUSv3 (IEEE Std 1003.1, 2003)-compliant here. http://www.opengroup.org/onlinepubs/007904975/utilities/ln.html says that ln should use unlink() on destination in case of "-f" option used. And conformant implementation of unlink's ".. path argument shall not name a directory unless the process has appropriate privileges and the implementation supports using unlink() on directories". Moreover, later, in informational section we see: "APPLICATION USAGE Applications should use rmdir() to remove a directory." FreeBSD's ln uses unlink() and behaves correctly on regular files, and it should not work that way with directories. Bug may be closed, I guess, and ln(1) may be changed back. One thing that we may do is to make ln print a warning in case of -f on a directory, but I personally think it's not worth it. -- Regards, Wartan. "Computers are not intelligent. They only think they are." From owner-freebsd-standards@FreeBSD.ORG Sat Jul 5 09:58:18 2003 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BDDF337B401 for ; Sat, 5 Jul 2003 09:58:18 -0700 (PDT) Received: from whale.sunbay.crimea.ua (whale.sunbay.crimea.ua [212.110.138.65]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9BA2D44001 for ; Sat, 5 Jul 2003 09:58:15 -0700 (PDT) (envelope-from ru@sunbay.com) Received: from whale.sunbay.crimea.ua (ru@localhost [127.0.0.1]) h65GwBVU041262 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Sat, 5 Jul 2003 19:58:12 +0300 (EEST) (envelope-from ru@sunbay.com) Received: (from ru@localhost) by whale.sunbay.crimea.ua (8.12.9/8.12.8/Submit) id h65GwB3n041257 for standards@FreeBSD.org; Sat, 5 Jul 2003 19:58:11 +0300 (EEST) (envelope-from ru) Date: Sat, 5 Jul 2003 19:58:11 +0300 From: Ruslan Ermilov To: standards@FreeBSD.org Message-ID: <20030705165811.GA39337@sunbay.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="8t9RHnE3ZwKMSgU+" Content-Disposition: inline User-Agent: Mutt/1.5.4i Subject: make -p X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Jul 2003 16:58:19 -0000 --8t9RHnE3ZwKMSgU+ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi there! A question: should we make ``make -p'' an alias for ``make -n -dg1'', for POSIX-200x comformance? Cheers, --=20 Ruslan Ermilov Sysadmin and DBA, ru@sunbay.com Sunbay Software Ltd, ru@FreeBSD.org FreeBSD committer --8t9RHnE3ZwKMSgU+ Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (FreeBSD) iD8DBQE/BwOjUkv4P6juNwoRAj3mAJ9XiqmQ+DxjlT0BosUSuuKdZkWQBQCeJcQG YD1TQjvBLlsckHVRpkNIruo= =wlMF -----END PGP SIGNATURE----- --8t9RHnE3ZwKMSgU+--