Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #199903

Re: Bash-Problem with cursor position after calling a function with READLINE_LINE

From "Thomas Schmitt" <scdbackup@gmx.net>
Newsgroups linux.debian.user
Subject Re: Bash-Problem with cursor position after calling a function with READLINE_LINE
Date 2018-09-08 17:10 +0200
Message-ID <wvN21-6MA-5@gated-at.bofh.it> (permalink)
References <wvtZn-3xO-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Hi,

David Wright wrote:
> As I posted, I get the same behaviour whichever shebang I have,
> any of bash|dash|sh.

That's probably because there is bash-ism in the script, except the
variable READLINE_LINE which the boss bash is supposed to have set.


> If the script has no shebang, then (I assume) the system will run a
> shell to execute it. As under correction above, it appears to start up
> this new shell with the same command line as the one it's running in.

https://manpages.debian.org/stretch/bash/bash.1.en.html says after having
explained how the file is looked up:

  If the search is successful, or if the command name contains one or
  more slashes, the shell executes the named program in a separate
  execution environment. Argument 0 is set to the name given, and the
  remaining arguments to the command are set to the arguments given,
  if any.

So it may be that the Linux kernel decides what to do. The man page
goes on with:

  If this execution fails because the file is not in executable format,
  and the file is not a directory, it is assumed to be a shell script,
  a file containing shell commands. A subshell is spawned to execute it.
  This subshell reinitializes itself, so that the effect is as if a new
  shell had been invoked to handle the script, with the exception that
  the locations of commands remembered by the parent (see hash below
  under SHELL BUILTIN COMMANDS) are retained by the child.

I'd expect that a script without "#!" falls in this category.
It seems that here we have the difference between Jessie and Stretch.

The man page then explains what happens if "#!" is seen:

  If the program is a file beginning with #!, the remainder of the first
  line specifies an interpreter for the program. The shell executes the
  specified interpreter on operating systems that do not handle this
  executable format themselves.

So again, it may be that the kernel decides to execute the interpreter
program with the script, or it can tell the shell to handle this on its
own.
Whatever happens, it works on Stretch.


My main suspect would be the statement in the middle quote about scripts
without "#!":

  "This subshell reinitializes itself"

Obviously this differs from the initialization of a freshly started new
shell, or from the cleanup in the momma shell before the fork and start
of an external program.


Have a nice day :)

Thomas

Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Bash-Problem with cursor position after calling a function with  READLINE_LINE Norbert Gruener <norbert@norbert-gruener.de> - 2018-09-06 18:10 +0200
  Re: Bash-Problem with cursor position after calling a function with READLINE_LINE "Thomas Schmitt" <scdbackup@gmx.net> - 2018-09-06 18:30 +0200
    Re: Bash-Problem with cursor position after calling a function with  READLINE_LINE Norbert Gruener <norbert@norbert-gruener.de> - 2018-09-06 18:50 +0200
      Re: Bash-Problem with cursor position after calling a function with READLINE_LINE "Thomas Schmitt" <scdbackup@gmx.net> - 2018-09-06 20:40 +0200
        Re: Bash-Problem with cursor position after calling a function with  READLINE_LINE Norbert Gruener <norbert@norbert-gruener.de> - 2018-09-07 08:40 +0200
  Re: Bash-Problem with cursor position after calling a function with READLINE_LINE Stefan Krusche <linux@stefan-krusche.de> - 2018-09-07 12:10 +0200
    Re: Bash-Problem with cursor position after calling a function with  READLINE_LINE Norbert Gruener <norbert@norbert-gruener.de> - 2018-09-07 14:50 +0200
      Re: Bash-Problem with cursor position after calling a function with READLINE_LINE Stefan Krusche <linux@stefan-krusche.de> - 2018-09-07 15:00 +0200
        [SOLVED} Re: Bash-Problem with cursor position after calling a  function with READLINE_LINE Norbert Gruener <norbert@norbert-gruener.de> - 2018-09-07 15:20 +0200
          Re: [SOLVED} Re: Bash-Problem with cursor position after calling a function with READLINE_LINE Stefan Krusche <linux@stefan-krusche.de> - 2018-09-07 15:30 +0200
        Re: Bash-Problem with cursor position after calling a function with  READLINE_LINE David Wright <deblis@lionunicorn.co.uk> - 2018-09-07 16:50 +0200
          Re: Bash-Problem with cursor position after calling a function with READLINE_LINE Stefan Krusche <linux@stefan-krusche.de> - 2018-09-07 18:40 +0200
            Re: Bash-Problem with cursor position after calling a function with  READLINE_LINE David Wright <deblis@lionunicorn.co.uk> - 2018-09-07 20:50 +0200
              Re: Bash-Problem with cursor position after calling a function with READLINE_LINE Stefan Krusche <linux@stefan-krusche.de> - 2018-09-08 12:50 +0200
                Re: Bash-Problem with cursor position after calling a function with READLINE_LINE Stefan Krusche <linux@stefan-krusche.de> - 2018-09-08 13:00 +0200
                Re: Bash-Problem with cursor position after calling a function with  READLINE_LINE Curt <curty@free.fr> - 2018-09-08 16:40 +0200
                Re: Bash-Problem with cursor position after calling a function with  READLINE_LINE Norbert Gruener <norbert@norbert-gruener.de> - 2018-09-13 12:30 +0200
              Re: Bash-Problem with cursor position after calling a function with READLINE_LINE "Thomas Schmitt" <scdbackup@gmx.net> - 2018-09-08 17:10 +0200
                Re: Bash-Problem with cursor position after calling a function with READLINE_LINE "Thomas Schmitt" <scdbackup@gmx.net> - 2018-09-08 18:20 +0200
    Re: Bash-Problem with cursor position after calling a function with  READLINE_LINE mick crane <mick.crane@gmail.com> - 2018-09-07 18:10 +0200
  Re: Bash-Problem with cursor position after calling a function with  READLINE_LINE Jude DaShiell <jdashiel@panix.com> - 2018-09-07 16:20 +0200
    Re: Bash-Problem with cursor position after calling a function with  READLINE_LINE Norbert Gruener <norbert@norbert-gruener.de> - 2018-09-13 12:30 +0200

csiph-web