Re: nullglob option breaks complex parameter expansion/deletion

2005-07-05 Thread Paul Jarc
[EMAIL PROTECTED] wrote:
 I had been using ${HOSTNAME%%.*} in my prompt to show the local
 host name portion of my full host name (e.g. localhost instead
 of localhost.localdomain).  After enabling the nullglob shell
 option, this pattern is being replaced by a null string.

How exactly are you setting your prompt?

 $ connectioninfo='${HOST%%.*} ${USER}'
 $ echo $connectioninfo

This doesn't demonstrate any misbehavior in parameter expansion,
because ${HOST%%.*} does not undergo parameter expansion at all - in
the first line, because it is quoted, and in the second line, because
it is the result of parameter expansion.  Try this instead:
$ echo ${HOST%%.*} ${USER}

This way, the HOST and USER parameters are expanded.  On my system, it
gives the same output regardless of whether $HOST contains a dot or
whether any existing files match.


paul


___
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash


Re: History timestamping does not respect TZ env variable

2005-07-05 Thread Paul Jarc
Chet Ramey [EMAIL PROTECTED] wrote:
 I am considering manipulating the `environ' variable when bash's list
 of exported variables changes.  That might be enough to make the libc
 getenv() work.

I can't quite tell what's going on in lib/sh/getenv.c, but could you
(if you don't already) use libc's putenv/setenv?


paul


___
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash


troubles with wide char support

2005-07-05 Thread Mike Frysinger
dont know why i didnt forward this earlier ...
http://bugs.gentoo.org/show_bug.cgi?id=69407

user has attached many patches but again these are out of my league :)
-mike


___
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash


Re: nullglob option breaks complex parameter expansion/deletion

2005-07-05 Thread Michael Wardle
I've come to a better understanding of how expansion occurs and now 
realize that this is not a bug.


Thanks to Chet for his time in responding to my messages.


___
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash


(submission) patch to 'parse.y'

2005-07-05 Thread William Park
Hi Chet,

While the iron is still hot, I am submitting the following modification
that I made to 'parse.y' and any other files related to features added
to 'parse.y'.  I would like to see some of them included in the next
release.

1.  
http://home.eol.ca/~parkw/index.html#here_file

Here-file.  File is read and the content is inserted into where
here-document would be.  From then on, it's here-document.


2.  +
http://home.eol.ca/~parkw/index.html#here_document

Similar to '-', but keeps relative indentation.  For the first
line, all indentations (spaces and tabs) are removed.  For the rest
of lines, all indentations are removed, and if it's greater than the
first's, then the difference is put back using tabs and spaces.  Tab
is 8 spaces.


3.  try
raise xxx
done in
xxx) echo x ;;
yyy) echo y ;;
esac
http://home.eol.ca/~parkw/index.html#exception

This implements exception handling, found in other languages.  New
construct 'try' and new builtin 'raise' are added.  As you can
guess, it is concatenation of loop contruct and case statement;
try-block is like while-loop that runs only once, and 'raise'
builtin within try-block is like 'break' builtin within loops.  And,
the exception is caught using 'case' statement.

When you raise string exception inside try-block, execution breaks
out, just like breaking out of loops.  But, with exception, it
breaks upward also, until it is caught by the case statement, which
is implemented using the same routine as standard case statement.


4.  for a,b,c in ... ; do
...
done
http://home.eol.ca/~parkw/index.html#for_while_until

Now that I can read from positional parameters and array, I don't
use it as often.  But, it's still useful.  The only thing is that
the variables must be typed explicitly.  They are not expanded.
Perhaps, it should be... not sure.  I think Zsh has something
similar.


5.  for/while/until ... ; do
...
done then
echo normal end
else
echo used break
fi
http://home.eol.ca/~parkw/index.html#for_while_until

This feature allows you to test how you exited the loop, without
using flags.  If you used 'break', then else-command will be
executed.  If you exited normally, then then-command will be
executed.  Python has something similar.

6.  case ... in
glob) ... ;;
regex)) ... ;;
...) command1 ;
...) command2 ;;
...) command3 ;;
esac
http://home.eol.ca/~parkw/index.html#case

I added regex support, so that you can specify regex using '))'.  If
there is any parenthesized group in regex, then it will return the
subgroups in SUBMATCH array variable, which is the same one used by
my 'match' builtin.  You can change it to what [[ string ~= regex ]]
uses.

Ksh and Zsh has ';' which will continue on to subsequent command,
rather than terminating the case statement.  With ';;', next
pattern will be tested, rather than terminating the case statement.


Okey, here is the relevant portion of diff file, which can also be found
at
http://home.eol.ca/~parkw/bashdiff/bashdiff-1.23rc.tar.gz


diff -rubBP -x autom4te.cache -x '*--old' -x doc -x po -x configure -x parse.c 
../bash-3.0/builtins/break.def ../bash/builtins/break.def
--- ../bash-3.0/builtins/break.def  2003-12-19 17:56:38.0 -0500
+++ ../bash/builtins/break.def  2005-06-27 01:36:18.0 -0400
@@ -130,3 +130,51 @@
 
   return (loop_level);
 }
+
+
+/***
+ * Raise string exception for try-block.  --William
+ */
+$BUILTIN raise
+$FUNCTION raise_builtin
+$SHORT_DOC raise [exception]
+Raise string exception (default '') which will be caught in 'try' block.
+$END
+
+char *exception = (char *)NULL;
+int try_level = 0; /* similar to loop_level above */
+
+#include bashgetopt.h/* loptend */
+
+
+int
+raise_builtin (list)
+WORD_LIST *list;
+{
+if (no_options (list))
+   return (EX_BADUSAGE);
+list = loptend; /* skip over possible `--' */
+
+if (exception) {
+   builtin_error (exception is already raised.);
+   return (EXECUTION_FAILURE);
+}
+if (try_level == 0) {
+#if defined (BREAK_COMPLAINS)
+   if (posixly_correct == 0)
+   builtin_error (meaningful only in a `try' block);
+#endif
+   return (EXECUTION_SUCCESS);
+}
+if (list == 0) {   /* 0 argument */
+   exception = savestring ();
+   return (EXECUTION_SUCCESS);
+}
+if (list-next == 0) { /* 1 argument */
+   exception = savestring (list-word-word);
+   return (EXECUTION_SUCCESS);
+}
+builtin_usage ();  /* 2 or more arguments */
+return (EX_BADUSAGE);
+}