• Re: stty permanently undef "start"

    From Greg Wooledge@21:1/5 to Franco Martelli on Wed Jul 10 16:00:01 2024
    On Wed, Jul 10, 2024 at 15:49:59 +0200, Franco Martelli wrote:
    ~$ stty start undef

    So, is there a way to permanently set "start" as "undef"? Maybe under /etc/? Should I put this command in .bashrc?

    You could -- but if you do so, you should definitely surround it with
    a check for stdin being a terminal (test -t 0 or equivalent).

    The proper way to disable XOFF/XON flow control, though, is to use
    "stty -ixon". The same disclaimer applies: only do it when you've
    verified that stdin is a terminal.

    test -t 0 && stty -ixon

    That should be safe to add to your .bashrc.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Nicolas George@21:1/5 to All on Wed Jul 10 16:10:01 2024
    Greg Wooledge (12024-07-10):
    You could -- but if you do so, you should definitely surround it with
    a check for stdin being a terminal (test -t 0 or equivalent).

    Does bash execute .bashrc when it is not interactive?

    Does bash think it is interactive when its input is not a tty?

    Regards,

    --
    Nicolas George

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Nicolas George@21:1/5 to All on Wed Jul 10 16:30:01 2024
    David Wright (12024-07-10):
    Someone might source .bashrc from a binary in order to
    access functions that are defined within it.

    That would be shooting oneself in the foot. No need to cater for them.

    Regards,

    --
    Nicolas George

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From David Wright@21:1/5 to Nicolas George on Wed Jul 10 16:30:01 2024
    On Wed 10 Jul 2024 at 16:00:48 (+0200), Nicolas George wrote:
    Greg Wooledge (12024-07-10):
    You could -- but if you do so, you should definitely surround it with
    a check for stdin being a terminal (test -t 0 or equivalent).

    Does bash execute .bashrc when it is not interactive?

    Someone might source .bashrc from a binary in order to
    access functions that are defined within it.

    Does bash think it is interactive when its input is not a tty?

    That would then be irrelevant.

    Cheers,
    David.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dan Ritter@21:1/5 to Franco Martelli on Wed Jul 10 16:50:01 2024
    Franco Martelli wrote:
    Hi everybody,

    I sometime use "rtorrent" (apt show rtorrent) to download isos and other big files. It happens that when I had to quit rtorrent by press Ctrl-Q I cannot because the key combination Ctrl-Q is trapped by the console due to "stty" default configuration:

    A glance at the wiki suggests that ctrl-Q just calls
    "system.shutdown.normal"

    So binding any other key to that command would be useful for
    you.

    Unfortunately, issue #817 says:

    "You can override/set key-bindings with rtorrent-ps, although
    you have to build your own ;) or get a precompiled build if
    you're lucky."

    Otherwise it would be ctrl-x, then system.shutdown.normal.

    -dsr-

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Greg Wooledge@21:1/5 to Nicolas George on Wed Jul 10 16:50:01 2024
    On Wed, Jul 10, 2024 at 16:27:16 +0200, Nicolas George wrote:
    David Wright (12024-07-10):
    Someone might source .bashrc from a binary in order to
    access functions that are defined within it.

    That would be shooting oneself in the foot. No need to cater for them.

    There are many legitimate or semi-legitimate situations where a .bashrc
    file might be read by a shell that's not running inside a terminal.

    One of them is if someone chooses to dot in ~/.profile from their
    ~/.xsession file, or something analogous to it. Or perhaps their
    operating system does this automatically in certain kinds of login.

    Another might be a scripted ssh session being run from cron, or some
    other parent that's not in a terminal. Analogously, the ancient
    predecessors of ssh (rsh, rexec) had exactly the same issues.

    When adding new commands to your shell dot files, always wrap commands
    that assume/require the presence of a terminal in a check for a terminal. You'll save yourself a *lot* of headaches.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Nicolas George@21:1/5 to All on Wed Jul 10 17:00:01 2024
    Greg Wooledge (12024-07-10):
    There are many legitimate or semi-legitimate situations where a .bashrc
    file might be read by a shell that's not running inside a terminal.

    One of them is if someone chooses to dot in ~/.profile from their
    ~/.xsession file, or something analogous to it. Or perhaps their
    operating system does this automatically in certain kinds of login.

    Another might be a scripted ssh session being run from cron, or some
    other parent that's not in a terminal. Analogously, the ancient
    predecessors of ssh (rsh, rexec) had exactly the same issues.

    What you describe is not legitimate, even semi-, these are hacks by
    people who cannot be bothered to organize their configuration properly.

    When adding new commands to your shell dot files, always wrap commands
    that assume/require the presence of a terminal in a check for a terminal. You'll save yourself a *lot* of headaches.

    I save myself a lot of headaches by proper places for each snippet of configuration. Which I can do because I use zsh instead of bash. zshrc
    for interactive shell, zshenv for all shells, zprofile for interactive
    login shells, etc.

    We should not encourage people to pile hacks upon hacks.

    Regards,

    --
    Nicolas George

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Greg Wooledge@21:1/5 to Nicolas George on Wed Jul 10 17:10:01 2024
    On Wed, Jul 10, 2024 at 16:50:38 +0200, Nicolas George wrote:
    Greg Wooledge (12024-07-10):
    There are many legitimate or semi-legitimate situations where a .bashrc file might be read by a shell that's not running inside a terminal.

    One of them is if someone chooses to dot in ~/.profile from their ~/.xsession file, or something analogous to it. Or perhaps their
    operating system does this automatically in certain kinds of login.

    Another might be a scripted ssh session being run from cron, or some
    other parent that's not in a terminal. Analogously, the ancient predecessors of ssh (rsh, rexec) had exactly the same issues.

    What you describe is not legitimate, even semi-, these are hacks by
    people who cannot be bothered to organize their configuration properly.

    hobbit:~$ echo 'echo I AM BASHRC' >> .bashrc
    hobbit:~$ ssh localhost date
    greg@localhost's password:
    I AM BASHRC
    Wed Jul 10 11:01:00 EDT 2024
    hobbit:~$

    Debian is, by your definition, a hack made by people who cannot be
    bothered to organize their configuration properly.

    Good to know.

    (I won't even bother explaining because you CLEARLY know better than I
    do about all topics. Enjoy your day.)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Nicolas George@21:1/5 to All on Wed Jul 10 17:10:02 2024
    Greg Wooledge (12024-07-10):
    hobbit:~$ echo 'echo I AM BASHRC' >> .bashrc
    hobbit:~$ ssh localhost date
    greg@localhost's password:
    I AM BASHRC
    Wed Jul 10 11:01:00 EDT 2024
    hobbit:~$

    ~ $ echo "I am in zshrc" >> .zshrc
    ~ $ ssh localhost date
    ~ $ ssh localhost date
    Wed Jul 10 17:05:01 CEST 2024

    Debian is, by your definition, a hack made by people who cannot be
    bothered to organize their configuration properly.

    Good to know.

    Indeed. Anything that uses bash is, because bash lacks one config file
    to make it possible to organize its configuration in a way that always
    work. Hence, when using bash, hacks upon hacks to work around that core
    issue.

    (I won't even bother explaining because you CLEARLY know better than I
    do about all topics. Enjoy your day.)

    The risk of passive-aggressive like that is that you risk to be right.

    Regards,

    --
    Nicolas George

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From [email protected]@21:1/5 to Nicolas George on Wed Jul 10 18:00:01 2024
    On Wed, Jul 10, 2024 at 05:08:20PM +0200, Nicolas George wrote:
    Greg Wooledge (12024-07-10):

    [...]

    (I won't even bother explaining because you CLEARLY know better than I
    do about all topics. Enjoy your day.)

    The risk of passive-aggressive like that is that you risk to be right.

    Folks, let it be. You're both smart, you're both (kinda) right. and you
    are both typically pretty helpful around here.

    Enjoy life :-)

    Cheers
    --
    t

    -----BEGIN PGP SIGNATURE-----

    iF0EABECAB0WIQRp53liolZD6iXhAoIFyCz1etHaRgUCZo6u+QAKCRAFyCz1etHa Rgj3AJwO9A9l2tS8OBXsPkwiAEYyxEJLYwCfWcm9KUL4/c5GMreP3FV5x8kTEcg=
    =K3x3
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Greg Wooledge@21:1/5 to All on Wed Jul 10 19:40:01 2024
    To summarize:

    * When configuring your shell dot files, make sure you DON'T write
    anything to stdout, unless you have verified that stdout is a
    terminal. Otherwise, it can mess up ssh sessions and other things.

    * Likewise, DON'T run stty, or other terminal manipulation commands,
    unless you've verified that stdin is a terminal. Otherwise, it
    can cause errors, which may have unpredictable results in some
    situations.

    * If you feel that this doesn't apply to you, fine.

    * For the rest of us, Debian has compiled its bash package with the
    option that causes it to read .bashrc when run under sshd, even
    when a command is given.

    * Also, some operating systems, such as SuSE, have historically
    configured their shells to read EVERY dot file regardless of
    invocation mode. So, thinking "but it shouldn't read .bashrc because
    I'm doing X, Y, or Z" may not necessarily be correct on such systems.

    * Also, some operating systems read your shell dot files during an X
    session startup, during which there is no terminal.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From songbird@21:1/5 to Franco Martelli on Thu Jul 11 01:00:01 2024
    Franco Martelli wrote:
    Hi everybody,

    I sometime use "rtorrent" (apt show rtorrent) to download isos and other
    big files. It happens that when I had to quit rtorrent by press Ctrl-Q I cannot because the key combination Ctrl-Q is trapped by the console due
    to "stty" default configuration:

    that is a strange choice of termination and i would
    actually consider it a bug in rtorrent, ESC or Ctrl-C
    should work for that purpose.

    ...

    songbird

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Greg Wooledge@21:1/5 to songbird on Thu Jul 11 01:00:02 2024
    On Wed, Jul 10, 2024 at 18:39:38 -0400, songbird wrote:
    Franco Martelli wrote:
    Hi everybody,

    I sometime use "rtorrent" (apt show rtorrent) to download isos and other big files. It happens that when I had to quit rtorrent by press Ctrl-Q I cannot because the key combination Ctrl-Q is trapped by the console due
    to "stty" default configuration:

    that is a strange choice of termination and i would
    actually consider it a bug in rtorrent, ESC or Ctrl-C
    should work for that purpose.

    Emacs and bash both use Ctrl-S to do stuff, and in both cases, you need
    to reconfigure your (virtual) terminal via stty(1) or equivalent to
    disable XOFF/XON flow control before it'll work.

    I'm sure these aren't the only three terminal programs that use ^S and/or
    ^Q as key bindings, under the assumption that you can press those keys
    without triggering flow control. They're the only ones I'm currently
    aware of, but I'd be shocked if there aren't more.

    Sadly, the days of designing software to accomodate actual hardware
    terminals are quite far behind us.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From songbird@21:1/5 to Nicolas George on Thu Jul 11 01:10:01 2024
    Nicolas George wrote:
    Greg Wooledge (12024-07-10):
    There are many legitimate or semi-legitimate situations where a .bashrc
    file might be read by a shell that's not running inside a terminal.

    One of them is if someone chooses to dot in ~/.profile from their
    ~/.xsession file, or something analogous to it. Or perhaps their
    operating system does this automatically in certain kinds of login.

    Another might be a scripted ssh session being run from cron, or some
    other parent that's not in a terminal. Analogously, the ancient
    predecessors of ssh (rsh, rexec) had exactly the same issues.

    What you describe is not legitimate, even semi-, these are hacks by
    people who cannot be bothered to organize their configuration properly.

    i see no problem with that at all.

    but for my own purposes i also like to do things for
    terminals when they open up (my session manager and the
    overall desktop will store multiple desktops and all of
    the terminals i have open in each of them when i ask it
    to).

    then in my .bashrc file i check to see what directory
    the terminal opens in and create aliases and other things
    for the specific project that i've got in that directory.
    it's very nice to have just the aliases and environment
    variables and other commands all set up and ready to go.

    it's not a hack, it's a way of being efficient and
    working the way that suits me. it also helps eliminate
    some problems because i can also set my various PATH
    environment variables to just what is needed and not
    any thing more.

    ...


    songbird

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From [email protected]@21:1/5 to Greg Wooledge on Thu Jul 11 03:10:01 2024
    On 7/10/24 18:57, Greg Wooledge wrote:
    On Wed, Jul 10, 2024 at 18:39:38 -0400, songbird wrote:
    that is a strange choice of termination and i would
    actually consider it a bug in rtorrent, ESC or Ctrl-C
    should work for that purpose.

    Emacs and bash both use Ctrl-S to do stuff, and in both cases, you need
    to reconfigure your (virtual) terminal via stty(1) or equivalent to
    disable XOFF/XON flow control before it'll work.

    I'm sure these aren't the only three terminal programs that use ^S and/or
    ^Q as key bindings, under the assumption that you can press those keys without triggering flow control. They're the only ones I'm currently
    aware of, but I'd be shocked if there aren't more.

    ^Q also quits LibreOffice apps, Thunderbird, Firefox, Pluma, and GIMP.

    --
    "God does not play dice" -- Einstein
    "Not only does God play dice, he sometimes throws
    them where they can't be seen." -- Stephen Hawking

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From [email protected]@21:1/5 to Greg Wooledge on Thu Jul 11 03:50:01 2024
    On 7/10/24 21:18, Greg Wooledge wrote:
    On Wed, Jul 10, 2024 at 21:01:41 -0400, [email protected] wrote:
    On 7/10/24 18:57, Greg Wooledge wrote:
    On Wed, Jul 10, 2024 at 18:39:38 -0400, songbird wrote:
    that is a strange choice of termination and i would
    actually consider it a bug in rtorrent, ESC or Ctrl-C
    should work for that purpose.

    Emacs and bash both use Ctrl-S to do stuff, and in both cases, you need
    to reconfigure your (virtual) terminal via stty(1) or equivalent to
    disable XOFF/XON flow control before it'll work.

    I'm sure these aren't the only three terminal programs that use ^S and/or >>> ^Q as key bindings, under the assumption that you can press those keys
    without triggering flow control. They're the only ones I'm currently
    aware of, but I'd be shocked if there aren't more.

    ^Q also quits LibreOffice apps, Thunderbird, Firefox, Pluma, and GIMP.

    Those are all X11 clients, though, yes? It's a completely different
    story compared to terminal programs.

    Ah yes, it'd be a weird choice for a terminal app.

    --
    LEO: Now is not a good time to photocopy your butt and staple it
    to your boss' face, oh no. Eat a bucket of tuna-flavored pudding
    and wash it down with a gallon of strawberry Quik. -- Weird Al

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Greg Wooledge@21:1/5 to [email protected] on Thu Jul 11 03:20:01 2024
    On Wed, Jul 10, 2024 at 21:01:41 -0400, [email protected] wrote:
    On 7/10/24 18:57, Greg Wooledge wrote:
    On Wed, Jul 10, 2024 at 18:39:38 -0400, songbird wrote:
    that is a strange choice of termination and i would
    actually consider it a bug in rtorrent, ESC or Ctrl-C
    should work for that purpose.

    Emacs and bash both use Ctrl-S to do stuff, and in both cases, you need
    to reconfigure your (virtual) terminal via stty(1) or equivalent to
    disable XOFF/XON flow control before it'll work.

    I'm sure these aren't the only three terminal programs that use ^S and/or ^Q as key bindings, under the assumption that you can press those keys without triggering flow control. They're the only ones I'm currently
    aware of, but I'd be shocked if there aren't more.

    ^Q also quits LibreOffice apps, Thunderbird, Firefox, Pluma, and GIMP.

    Those are all X11 clients, though, yes? It's a completely different
    story compared to terminal programs.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From songbird@21:1/5 to Greg Wooledge on Thu Jul 11 07:00:01 2024
    Greg Wooledge wrote:
    ...
    Sadly, the days of designing software to accomodate actual hardware
    terminals are quite far behind us.

    true.

    having been annoyed by the quit keys of Firefox i just
    went and found the way to turn that off. been burned by
    that one too many times and i'd still not looked into it
    but i hope now that at least i've gotten that one nixed.


    songbird

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Nicolas George@21:1/5 to All on Thu Jul 11 10:20:01 2024
    songbird (12024-07-10):
    but for my own purposes i also like to do things for
    terminals when they open up (my session manager and the
    overall desktop will store multiple desktops and all of
    the terminals i have open in each of them when i ask it
    to).

    This is absolutely legitimate.

    Note that tings in .bashrc will not affect terminals that run directly
    another program, like “xterm -e vim”.

    then in my .bashrc file i check to see what directory
    the terminal opens in and create aliases and other things
    for the specific project that i've got in that directory.
    it's very nice to have just the aliases and environment
    variables and other commands all set up and ready to go.

    This too is absolutely fine. I have even seen done this in pre-prompt
    functions to have it exec when changing directory in the same shell.

    it's not a hack

    This is not the hack. The hack comes when (1) you put things to
    initialize the extended environment in .bashrc, (2) you source .bashrc
    when it is not sourced.

    All because this idiot bash does not have a .bashenv.

    Regards,

    --
    Nicolas George

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Greg Wooledge@21:1/5 to Max Nikulin on Thu Jul 11 18:00:02 2024
    On Thu, Jul 11, 2024 at 22:43:58 +0700, Max Nikulin wrote:
    On 10/07/2024 20:55, Greg Wooledge wrote:
    test -t 0 && stty -ixon

    I have a question opposite to the original one. Is it possible to disable xon&xoff for bash prompt, but enable it while foreground commands are running? Sometimes I use [Ctrl+s] to pause verbose output of some tool. On the other hand I do not mind to use forward search in readline history.

    In theory... you could run "stty -ixon" in the PROMPT_COMMAND variable,
    and "stty ixon" in a DEBUG trap.

    The DEBUG trap is run before each command, and the PROMPT_COMMAND
    commands are run before displaying the prompt. So, it *should* work,
    as long as you're aware that commands might change the terminal modes themselves, and you aren't using DEBUG for anything else that would
    interfere.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Vincent Lefevre@21:1/5 to Nicolas George on Sat Jul 27 00:20:01 2024
    On 2024-07-10 16:00:48 +0200, Nicolas George wrote:
    Greg Wooledge (12024-07-10):
    You could -- but if you do so, you should definitely surround it with
    a check for stdin being a terminal (test -t 0 or equivalent).

    Does bash execute .bashrc when it is not interactive?

    Yes, it may execute it. From the bash(1) man page:

    If bash determines it is being run non-interactively in this
    fashion, it reads and executes commands from /etc/bash.bashrc
    and ~/.bashrc, if these files exist and are readable.

    --
    Vincent Lef�vre <[email protected]> - Web: <https://www.vinc17.net/>
    100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
    Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)