bug in 4.2

2014-01-29 Thread Csaba Toth

Hi,

If you set PROMPT_DIRTRIM, in some cases strange output displayed in the 
prompt. I found an issue inside the trim_pathname() function, that uses 
memcpy() to copy head and tail together. That should not be used if the 
memory is overlapped and memmove() shall be used instead.


Please find my enclosed patch.

Have a nice day!

Csaba
--- orig/bash-4.2/general.c	2010-12-12 21:06:27.0 +0100
+++ modified/bash-4.2/general.c	2014-01-29 12:45:49.762326928 +0100
@@ -766,7 +766,7 @@
   *nbeg++ = '.';
 
   nlen = nend - ntail;
-  memcpy (nbeg, ntail, nlen);
+  memmove(nbeg, ntail, nlen);
   nbeg[nlen] = '\0';
 
   return name;


Re: bug in 4.2

2014-01-29 Thread Chet Ramey
On 1/29/14 6:53 AM, Csaba Toth wrote:
 Hi,
 
 If you set PROMPT_DIRTRIM, in some cases strange output displayed in the
 prompt. I found an issue inside the trim_pathname() function, that uses
 memcpy() to copy head and tail together. That should not be used if the
 memory is overlapped and memmove() shall be used instead.

Thanks for the report.  This was reported and fixed in March, 2013, and
the fixed version is part of the bash development git branch.

http://lists.gnu.org/archive/html/bug-bash/2013-03/msg00047.html

(Your patch is exactly right, by the way.)

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/



let's establish BASH_MINIMUM_TIME_BETWEEN_INTERACTIVE_COMMAND

2014-01-29 Thread jidanni
Gentlemen, I have once again come up with a million dollar idea for bash,
revolutionizing the shell world.

As we all know, nobody in their right mind could type more than one
command per second into bash when in interactive mode.

So let's establish BASH_MINIMUM_TIME_BETWEEN_INTERACTIVE_COMMAND=1.0

Any faster than that means the user has once again by accident pasted
wads and wads of some essay into bash!

Bash should simply print error message(s) and _not add those lines to history_.

Voila, the damage is limited to just the first line being interpreted,
instead of feeding your (even root) shell all 1000 lines of random junk!

Sure, the default could be BASH_MINIMUM_TIME_BETWEEN_INTERACTIVE_COMMAND=0
so it still could be available just for users that need it (badly like me.)



Re: let's establish BASH_MINIMUM_TIME_BETWEEN_INTERACTIVE_COMMAND

2014-01-29 Thread Chris Down
On 2014-01-30 09:18:19 +0800, jida...@jidanni.org wrote:
 So let's establish BASH_MINIMUM_TIME_BETWEEN_INTERACTIVE_COMMAND=1.0

Well, you can do this with PROMPT_COMMAND='sleep 1'. I don't see the
need for another internal variable to do this.


pgpTYMNSu6HsQ.pgp
Description: PGP signature


Re: let's establish BASH_MINIMUM_TIME_BETWEEN_INTERACTIVE_COMMAND

2014-01-29 Thread Eduardo A . Bustamante López
On Thu, Jan 30, 2014 at 10:44:30AM +0800, Chris Down wrote:
 On 2014-01-30 09:18:19 +0800, jida...@jidanni.org wrote:
  So let's establish BASH_MINIMUM_TIME_BETWEEN_INTERACTIVE_COMMAND=1.0
 
 Well, you can do this with PROMPT_COMMAND='sleep 1'. I don't see the
 need for another internal variable to do this.
How would that work to avoid filling the prompt with the paste buffer
when I fat finger and paste a whole email to the prompt? It will just
slow down the process, but not cancel it.

What I understand that's being proposed is a feature available in
some IRC clients, where the client prompts you if it detects that
you're inputting more than 2 lines in a short period.

This variable with a really long name would invalidate a sequence of
commands if the commands are input in rapid succesion (as when input
through pasting).


-- 
Eduardo Alan Bustamante López



Re: let's establish BASH_MINIMUM_TIME_BETWEEN_INTERACTIVE_COMMAND

2014-01-29 Thread Bob Proulx
Eduardo A. Bustamante López wrote:
 Chris Down wrote:
  Well, you can do this with PROMPT_COMMAND='sleep 1'. I don't see the
  need for another internal variable to do this.

 How would that work to avoid filling the prompt with the paste buffer
 when I fat finger and paste a whole email to the prompt? It will just
 slow down the process, but not cancel it.

It would give you plenty of time to hit Control-C to interrupt it.
Try it and you will see.

Bob



Re: let's establish BASH_MINIMUM_TIME_BETWEEN_INTERACTIVE_COMMAND

2014-01-29 Thread Eduardo A . Bustamante López
On Wed, Jan 29, 2014 at 09:03:12PM -0700, Bob Proulx wrote:
 Eduardo A. Bustamante López wrote:
  Chris Down wrote:
   Well, you can do this with PROMPT_COMMAND='sleep 1'. I don't see the
   need for another internal variable to do this.
 
  How would that work to avoid filling the prompt with the paste buffer
  when I fat finger and paste a whole email to the prompt? It will just
  slow down the process, but not cancel it.
 
 It would give you plenty of time to hit Control-C to interrupt it.
 Try it and you will see.
 
 Bob
 
I understand. Indeed it seems that it's a good solution and requires
no additional features. I did test it.

-- 
Eduardo Alan Bustamante López



Re: let's establish BASH_MINIMUM_TIME_BETWEEN_INTERACTIVE_COMMAND

2014-01-29 Thread Chris Down
On 2014-01-29 21:03:12 -0700, Bob Proulx wrote:
 Eduardo A. Bustamante López wrote:
  Chris Down wrote:
   Well, you can do this with PROMPT_COMMAND='sleep 1'. I don't see the
   need for another internal variable to do this.
 
  How would that work to avoid filling the prompt with the paste buffer
  when I fat finger and paste a whole email to the prompt? It will just
  slow down the process, but not cancel it.
 
 It would give you plenty of time to hit Control-C to interrupt it.
 Try it and you will see.

Yeah, that's what I had in mind.

The one thing worth mentioning is that the first line will still get
executed immediately. PROMPT_COMMAND is run just before PS1 is printed.

One way to get around this is to use the debug trap instead:

shopt -s extdebug
trap 'sleep 1' DEBUG


pgp_8wA6L1pN1.pgp
Description: PGP signature


Re: let's establish BASH_MINIMUM_TIME_BETWEEN_INTERACTIVE_COMMAND

2014-01-29 Thread Aharon Robbins
In article mailman.13136.1391044881.10748.bug-b...@gnu.org,
 jida...@jidanni.org wrote:
Gentlemen, I have once again come up with a million dollar idea for bash,
revolutionizing the shell world.

As we all know, nobody in their right mind could type more than one
command per second into bash when in interactive mode.

So let's establish BASH_MINIMUM_TIME_BETWEEN_INTERACTIVE_COMMAND=1.0

I bet Chet would be happy to evaluate a patch to the code and documentation
once you submit it (the other proposed solutions notwithstanding).

Arnold
-- 
Aharon (Arnold) Robbins arnold AT skeeve DOT com
P.O. Box 354Home Phone: +972 8 979-0381
Nof Ayalon
D.N. Shimshon 9978500   ISRAEL