bug-bash
[Top][All Lists]
Advanced

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

Re: corrupted input after size function (input that's not recorded by ba


From: Linda Walsh
Subject: Re: corrupted input after size function (input that's not recorded by bash)
Date: Thu, 13 Jun 2013 16:42:36 -0700
User-agent: Thunderbird



Chris F.A. Johnson wrote:
On Thu, 13 Jun 2013, Linda Walsh wrote:
I have a small function in my bashrc:

function showsize () {\
 local s=$(stty size); local o="(${s% *}x${s#* })"; s="${#o}";\
 echo -n $o; while ((s-- > 0));do echo -ne "\b"; done; \
}
export -f showsize
trap showsize SIGWINCH
---
That has the effect of showing me my current window size
when I resize it.

The odd thing is, if I use it while at a bash input prompt --
any command I type has the first word ignored.

so if I type:
echo cmd

If 'cmd' is not a typo you can use command-not-found to lookup the package that contains it, like this:
   cnf cmd
---
But then I re-edit the line (in vi-mode, ESC-k, it shows me I typed
echo cmd -- and, indeed, if I hit return, it echo's the word 'cmd' w/no error.

So how can my showsize function be mangling the input in a way that
prevents proper execution, but isn't recorded by bash?

(this has been one of those things that's bothered me for years, but
never been important enough to even ask about... I thought I'd look at it
to fix it, but still don't see why it does what it does).

Any clues?

   The baskspaces (\b) are erasing your input, not the function's
   output.
---
        The idea of the backspaces was to put the cursor back in the original
position -- not erase anything.  They are sent to the same file
handle (STDOUT) as the terminal size info  -- they aren't piped to STDIN.

        Second problem with that theory, I resize the window and see
the output... THEN, I type a command and the first word is ignored.
They couldn't erase my typing before I typed it could they?  I admit
to being a bit rusty on my temporal programming theory, but I don't recall
post-deletion of future data to be an issue if you are not, at least,
using quantum computing. ;-|  'Sides -- another problem with that...
when I re-edit the line, Bash has recorded the line as typed.  with no
erasures of the 1st word being recorded.  Hmmm.. now if Bash displayed
the re-edited line outside the normal timeframe, that could explain that
too... but um... I'm not convinced that that bash would be executing
outside my timeframe....(i.e. no way! I don't see it). ;-)





reply via email to

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