On 8/27/21, 5:22 PM, Dabrien 'Dabe' Murphy wrote:
On 8/27/21, 4:09 PM, Chet Ramey wrote:
That circumstance is a pathname consisting solely of one or more slashes,
separated from the previous word by whitespace. I'll fix it.
The code has been like this since January, 2004. That's pretty dated.
I guess I was just hoping somebody smarter than me [that's not hard] would
bust out some super fu and say something like, "Have you tried adding
'set word-break-chars [blah]' to your .inputrc ?"  «grin»
[FWIW, I'm sure the "bug-bash" list isn't actually the right venue for 
this, and I
apologize, but I figured I'd send this along as a reply, just for 
posterity...]
Although the following doesn't — slash *CAN'T* ? — save to the kill ring 
(it doesn't
even attempt to keep track of $READLINE_MARK), I came up with the following
"clever workaround" [read: "gross hack"] to wrangle even bash 3.2 into submission:
prompt% less ~/.bash_readline
...
### Set up macro (shell function) to eval
unix_filename_rubout() {
    local removed_space=0 removed_slash=0

    while [[ ${READLINE_POINT:-0} -gt 0 ]] &&
          [[ ${READLINE_LINE: $((READLINE_POINT - 1)): 1} =~ ^\ ?$ ]]; do
READLINE_LINE="${READLINE_LINE: 0: $((READLINE_POINT - 1))}${READLINE_LINE: $((READLINE_POINT--))}"
        removed_space=1
    done

    while [[ ${READLINE_POINT:-0} -gt 0 ]] &&
          [[ ${READLINE_LINE: $((READLINE_POINT - 1)): 1} =~ ^/?$ ]]; do
READLINE_LINE="${READLINE_LINE: 0: $((READLINE_POINT - 1))}${READLINE_LINE: $((READLINE_POINT--))}"
        removed_slash=1
    done

if ! { [[ ${removed_slash:-0} -ge 1 ]] && [[ ${removed_space:-0} -ge 1 ]]; }; then
        removed_space=0
        while [[ ${READLINE_POINT:-0} -gt 0 ]] &&
[[ ${READLINE_LINE: $((READLINE_POINT - 1)): 1} =~ ^\ ?$ ]]; do READLINE_LINE="${READLINE_LINE: 0: $((READLINE_POINT - 1))}${READLINE_LINE: $((READLINE_POINT--))}"
            removed_space=1
        done
    else
        removed_space=0
    fi

if ! { [[ ${removed_slash:-0} -ge 1 ]] && [[ ${removed_space:-0} -ge 1 ]]; }; then
        while [[ ${READLINE_POINT:-0} -gt 0 ]] &&
! [[ ${READLINE_LINE: $((READLINE_POINT - 1)): 1} =~ ^[\ /]?$ ]]; do READLINE_LINE="${READLINE_LINE: 0: $((READLINE_POINT - 1))}${READLINE_LINE: $((READLINE_POINT--))}"
        done
    fi
}

stty werase undef
bind -x '"\C-w": unix_filename_rubout'


You know what they say... "If it's stupid but it works, it isn't stupid." «grin»
Thanks!  :-D

--
:- Dabe

Reply via email to