bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bash/set - bad expansion for function while used as input


From: Stanislav Brabec
Subject: Re: bash/set - bad expansion for function while used as input
Date: Sat, 23 Dec 2000 02:01:59 +0100
User-agent: Mutt/1.2.5i

On Thu, Dec 21, 2000 at 12:17:54PM -0500, Chet Ramey wrote:
> > Bash Version: 2.04
> > Patch Level: 0
> > Release Status: release
> >                                    =20
> > Description:
> >        set [--abefhkmnptuvxBCHP] [-o option] [arg ...]
> >               Without options, the name and value of each shell variable
> >               are displayed in a format that  can be  reused  as input.
> 
> What solution do users prefer?  POSIX.2 says only variables should be
> printed, but printing functions seems like a reasonable thing to do.
> How about printing only variables in POSIX mode, and printing functions
> (but not as pseudo-assignment statements) when not in POSIX mode?
> 

I like functionallity "as is", but I have complained about unusability
of output of functions. I am adding small patch, which solves my problem
- if var is a function, it will not be dumped as

fnc=()
{
foo
}

but in format

fnc()
{
foo
}

which is reusable. But I don't know, if there's some standard, which
can be broken by my patch. With this patch following script gives
intuitivelly expected empty output.

-------------
#! /bin/bash
function bad_func()
{
  echo `echo This should not be printed!`
}
set >bad_func_dump
function bad_func()
{
  This is fuzzy!
}
. bad_func_dump 2>/dev/null
set
-------------


-- 
Stanislav Brabec


--- bash-2.04/variables.c.orig  Tue Mar 14 17:36:18 2000
+++ bash-2.04/variables.c       Sat Dec 23 01:42:07 2000
@@ -793,7 +793,7 @@
 {
   if (function_p (var) && var->value)
     {
-      printf ("%s=", var->name);
+      printf ("%s", var->name);
       print_var_function (var);
       printf ("\n");
     }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]