Skip to content

TM Terminal: no shell prompt with bash or zsh #831

Closed

Description

@space88man

Describe the bug
When I run a local terminal with bash / zsh in TM Terminal, no shell prompt appears.

To Reproduce

Steps to reproduce the behavior:

  1. Window -> Preferences -> TM Terminal -> Local Terminal
  2. Shell Command: use /bin/bash or /bin/zsh
  3. Open a new Local Terminal
  4. No shell prompt appears; no messages in Error log

Expected behavior
Shell prompt

Screenshots
/bin/bash or /bin/zsh:

Screenshot from 2024-06-19 06-55-02

/bin/fish:

Screenshot from 2024-06-19 07-01-25

Version Information (please complete the following information):

  • Linux (x86_64, Fedora 40)
  • Eclipse Version from Help -> 2024-06
  • CDT Version from Help -> About -> Installation Details -> 11.6.0

Additional context

  • both /bin/bash /bin/zsh show this no-output issue
  • shell can be closed with Ctrl+D; shell is shown running using ps
  • the shell is semi-functional: if I type emacs blindly the child program is really run
  • programs with text output (e.g. ls) don't show output
  • vim: surprisingly appears on screen; running a program under vim :! ls works
  • if the shell is /bin/fish - it shows prompt: running /bin/bash under /bin/fish shows the same issue; there is no bash prompt
  • with blind bash/zsh: non-working curses programs - top, nano, htop
  • with blind bash/zsh: working curses programs - ipython, vim , neovim
  • with blind bash/zsh: it is possible to run fish and the prompt appears
  • if bash is the shell at the other end of a SSH Terminal it works

Other OSes

  • works on Pop!_OS 22.04, i.e. does not reproduce
  • works on Ubuntu 24.04., i.e. does not reproduce

zsh

If I remove ~/.zshrc I will get the zsh customisation process; after ~/.zshrc is written it then goes into the no-output state

Activity

  1. space88man commented on Jun 18, 2024

    @space88man
    Author

    Ping @jonahgraham
    This looks the same as #776 - so may not be macos specific

  2. space88man commented on Jun 19, 2024

    @space88man
    Author

    Update : it is related to shell customisation; i.e. all the stuff that fedora puts into /etc/profile.d/*sh; going to take a while to bisect that...

    Root cause is Fedora's /etc/profile.d/vte.sh: pasting here for reference

    # Copyright © 2012 Christian Persch
    #
    # This program is free software: you can redistribute it and/or modify
    # it under the terms of the GNU General Public License as published by
    # the Free Software Foundation, either version 3 of the License, or
    # (at your option) any later version.
    #
    # This program is distributed in the hope that it will be useful,
    # but WITHOUT ANY WARRANTY; without even the implied warranty of
    # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    # GNU General Public License for more details.
    #
    # You should have received a copy of the GNU General Public License
    # along with this program.  If not, see <https://www.gnu.org/licenses/>.
    
    # Not bash or zsh?
    [ -n "${BASH_VERSION:-}" -o -n "${ZSH_VERSION:-}" ] || return 0
    
    # Not an interactive shell?
    [[ $- == *i* ]] || return 0
    
    # Not running under vte?
    [ "${VTE_VERSION:-0}" -ge 3405 ] || return 0
    
    # TERM not supported?
    case "$TERM" in
        xterm*|vte*|gnome*) :;;
        *) return 0 ;;
    esac
    
    __vte_shell_precmd() {
        local command=$(HISTTIMEFORMAT= history 1 | sed 's/^ *[0-9]\+ *//')
        command="${command//;/ }"
        printf '\033]777;notify;Command completed;%s\033\\\033]777;precmd\033\\' "${command}"
    }
    
    __vte_osc7 () {
        printf "\033]7;file://%s%s\033\\" "${HOSTNAME}" "$(/usr/libexec/vte-urlencode-cwd)"
    }
    
    __vte_prompt_command() {
        local pwd='~'
        [ "$PWD" != "$HOME" ] && pwd=${PWD/#$HOME\//\~\/}
        pwd="${pwd//[[:cntrl:]]}"
        printf "\033]0;%s@%s:%s\033\\" "${USER}" "${HOSTNAME%%.*}" "${pwd}"
        __vte_shell_precmd
        __vte_osc7
    }
    
    if [[ -n "${BASH_VERSION:-}" ]]; then
    
        # Newer bash versions support PROMPT_COMMAND as an array. In this case
        # only add the __vte_osc7 function to it, and leave setting the terminal
        # title to the outside setup.
        # On older bash, we can only overwrite the whole PROMPT_COMMAND, so must
        # use the __vte_prompt_command function which also sets the title.
    
        if [[ "$(declare -p PROMPT_COMMAND 2>&1)" =~ "declare -a" ]]; then
    	PROMPT_COMMAND+=(__vte_shell_precmd)
    	PROMPT_COMMAND+=(__vte_osc7)
    	PS0=$(printf "\033]777;preexec\033\\")
        else
    	PROMPT_COMMAND="__vte_prompt_command"
    	PS0=$(printf "\033]777;preexec\033\\")
        fi
    
        # Shell integration
        if [[ "$PS1" != *\]133\;* ]]; then
    
            # Enclose the primary prompt between
            # ← OSC 133;D;retval ST (report exit status of previous command)
            # ← OSC 133;A ST (mark beginning of prompt)
            # → OSC 133;B ST (mark end of prompt, beginning of command line)
            PS1='\[\e]133;D;$?\e\\\e]133;A\e\\\]'"$PS1"'\[\e]133;B\e\\\]'
    
            # Prepend OSC 133;L ST for a conditional newline if the previous
            # command's output didn't end in one.
            # This is not done here by default, in order to provide the default
            # visual behavior of shells. Uncomment if you want this feature.
            #PS1='\[\e]133;L\e\\\]'"$PS1"
    
            # iTerm2 doesn't touch the secondary prompt.
            # Konsole encloses it between 133;A and 133;B.
            # For efficient jumping between commands, we follow iTerm2 by default
            # and don't mark PS2 as prompt. Uncomment if you want to mark it.
            #PS2='\[\e]133;A\e\\\]'"$PS2"'\[\e]133;B\e\\\]'
    
            # Mark the beginning of the command's output by OSC 133;C ST.
            # '\r' ensures that the kernel's cooked mode has the right idea of
            # the column, important for handling TAB followed by BS keypresses.
            # Prepend to the user's PS0 to preserve whether it ends in '\r'.
            # Note that bash doesn't support the \[ \] markers here.
            PS0='\e]133;C\e\\\r'"${PS0:-}"
        fi
    
    elif [[ -n "${ZSH_VERSION:-}" ]]; then
        precmd_functions+=(__vte_osc7)
    
        # Shell integration (see the bash counterpart for more detailed comments)
        if [[ "$PS1" != *\]133\;* ]]; then
    
            # Enclose the primary prompt between D;retval, A and B.
            PS1=$'%{\e]133;D;%?\e\\\e]133;A\e\\%}'"$PS1"$'%{\e]133;B\e\\%}'
    
            # Prepend L for conditional newline (skipped).
            #PS1=$'%{\e]133;L\e\\%}'"$PS1"
    
            # Secondary prompt (skipped).
            #PS2=$'%{\e]133;A\e\\%}'"$PS2"$'%{\e]133;B\e\\%}'
    
            # Mark the beginning of output by C.
            # The execution order is: the single function possibly hooked up
            # in $preexec, followed by all the functions hooked up in the
            # $preexec_functions array. Ensure that we are the very first.
            __vte_preexec() {
                printf '\e]133;C\e\\\r'
            }
            preexec_functions=(__vte_preexec $preexec $preexec_functions)
            unset preexec
        fi
    
    fi
    
    return 0
    
  3. jonahgraham commented on Jun 19, 2024

    @jonahgraham
    Member

    Thanks @space88man you have provided enough information for me to figure out what is going wrong.

    The problem is the string terminator implementation in the terminal. Escape strings (like OSC 133 commands) can end with BEL or ESC \. In the terminal only the BEL terminator was implemented:

    case ANSISTATE_EXPECTING_OS_COMMAND:
    // A BEL (\u0007) character marks the end of the OSC sequence.
    if (character == '\u0007') {
    ansiState = ANSISTATE_INITIAL;
    processAnsiOsCommand();

    Although ESC \ has been part of the spec for a long time, I guess most places didn't use it until recently. gnome started using it very recently with this commit which basically supports https://iterm2.com/documentation-escape-codes.html for allowing terminals to navigate the terminal output better.

    For now I can properly ignore the unsupported sequences and I will provide a PR for that in a moment.

  4. jonahgraham commented on Jun 19, 2024

    @jonahgraham
    Member

    In addition, the terminal didn't properly handle badly formed clients, quoted from here:

    If an application does not send the string terminator, that is also
    an error from the standpoint of a user.  To accommodate users of
    those applications, xterm has resource settings which allow
    workarounds:
    
    o   The Linux console's palette sequences do not use a string
        terminator.  The [brokenLinuxOSC](https://invisible-island.net/xterm/manpage/xterm.html#VT100-Widget-Resources:brokenLinuxOSC) resource setting tells xterm to
        ignore those particular sequences.
    
    o   The terminal should accept single-byte controls within the
        string.  But some applications omit a string terminator, like
        the Linux console.  The [brokenStringTerm](https://invisible-island.net/xterm/manpage/xterm.html#VT100-Widget-Resources:brokenStringTerm) resource setting tells
        xterm to exit string mode if it decodes a common control
        character such as carriage return before the string terminator.
    

    had the terminal handled it properly we would have been ok too.

  5. space88man commented on Jun 20, 2024

    @space88man
    Author

    @jonahgraham - can this go into a p2 update before 2024-09?

  6. jonahgraham commented on Jun 20, 2024

    @jonahgraham
    Member

    Yes it can and will - I will publish an update soon. It would be helpful if you can test it before it is published. In a couple of hours the main branch should be built here https://ci.eclipse.org/cdt/job/cdt/job/main/415/artifact/releng/org.eclipse.cdt.repo/target/repository/ and then I'll backport the fix to the current release branch.

    (reopening until fixed on the release branch)

  7. space88man commented on Jun 20, 2024

    @space88man
    Author

    It would be helpful if you can test it before it is published.

    Tested on 2024-06 by munging the VT100*.class files from terminal.control_5.5.400 jar into the existing 5.5.300 jar. Also tested by upgrading just the TM components into 2024-06.

    All work - bash, zsh, tmux, screen as shell commands.

    Thank you!

  8. added this to the 11.6.1 milestone on Jun 23, 2024
  9. jonahgraham commented on Jul 2, 2024

    @jonahgraham
    Member

    Fixed on 11.6 branch which should be released soon as 11.6.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions