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: Dennis Williamson
Subject: Re: corrupted input after size function (input that's not recorded by bash)
Date: Thu, 13 Jun 2013 21:05:10 -0500

On Jun 13, 2013 4:09 PM, "Linda Walsh" <bash@tlinx.org> wrote:
>
>
>
> Greg Wooledge wrote:
>>
>> On Thu, Jun 13, 2013 at 12:58:02PM -0700, Linda Walsh wrote:
>>>
>>> So how can my showsize function be mangling the input in a way that
>>> prevents proper execution, but isn't recorded by bash?
>>
>>
>> What makes you believe it's this function that's causing your problem,
>> and not something else, such as a PROMPT_COMMAND variable?  Or some
>> command which is altering the terminal in some bizarre way?
>
> --------------
>
> FWIW, my prompt is a bit complex, but it's worked for years, so I
> sorta doubt it is the problem:
>
>   read _CRST < <(tput sgr0)   #Reset
>   read _CRed < <(tput setaf 1)  #Red
>   read _CBLD < <(tput bold)   #Bold
>   declare _prompt_open="" _prompt_close="" _prompt=">"
>   declare _disp_port=${DISPLAY/[^:]*:/}
>   [[ $UID -eq 0 ]] && {
>     _prompt_open="$_CBLD$_CRed"
>     _prompt="#"
>     _prompt_close="$_CRST"
>   }
>   PS1='\['"$_prompt_open"'\]$(spwd "$PWD"
)'"$_prompt"'\['"$_prompt_close"'\] ';
>
>   if [[ -n ${REMOTEHOST:-""} ]]; then
>     function titlebar { \
>       printf "\033]1;${USER}@${HOSTNAME}:%q\007" "$(spwd "$PWD")" ;\
>     }
>     export -f titlebar
>
>     PS1='\[$(titlebar)'"$_prompt_open"'\]${HOSTNAME}:$(spwd
"$PWD")'"$_prompt"'\['"$_prompt_close"'\] '
>   fi
> ====
> Puts out shortened path on my prompt and on the window title bar.
> The title bar thing is very handy when you have a bunch of windows
minimized
> and want to find a tty window that is in a particular directory...as I
move
> my mouse over the minimized windows, it shows me the title -- so I see
the path
> of each window..
>
>
> #==============swd is defined in another file:
>
> alias int=declare\ -i _e=echo _pf=printf exp=export ret=return
> exp __dpf__='local -a PF=(
>                 "/$1/$2/$3/../\${$[$#-1]}/\${$#}"
>                 "/$1/$2/../\${$[$#-1]}/\${$#}"
>                 "/$1/../\${$[$#-1]}/\${$#}"
>                 "/$1/../\${$#}"
>                 ".../\${$#}"
>                 "..." )'
> function spwd () {  \
>   (($#)) || { _e "spwd called with null arg"; return 1; }; \
>   int w=COLUMNS/2                         ;\
>   ( _pf -v _p "%s" "$1" ; export IFS=/    ;\
>     set $_p; shift; unset IFS             ;\
>     t="${_p#${HOME%${USER}}}"             ;\
>     int tl=${#t}                          ;\
>     if (($#<=6 && tl<w));then ((tl<=2)) && \
>       { _e -En "${_p}";return 0; }        ;\
>     else                                   \
>       eval "$__dpf__"                     ;\
>       int i pfl=${#PF[*]}                 ;\
>       for ((i=0; i<pfl; ++i)); do eval     \
>         "_pf -v _pa %s \"${PF[i]}\""      ;\
>         _p="$(eval "_pf %s \"$_pa\"")"    ;\
>         ((${#_p}<w)) && break;  done      ;\
>     fi                                    ;\
>     _e -En "${_p#${HOME%${USER}}}" )
> }
> --------------
>
> It's the way I might wish \w|\W to work in bash...
>
> PF is my array of formats.  __dpf__ is a string that will define the array
> (since I can't export arrays n hashes, I export things to define them)
>
> It adopts longer paths if the paths all fit in the space, but shorter ones
> when the path doesn't.. I let take up to half the screen, which is
> a fair amount, but if I'm buried that deep somewhere, clues are handy.
>

Why are you doing

read _CRST < <(tput sgr0)

instead of

_CRST=$(tput sgr0)


reply via email to

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