Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

HOLY MACRO!


devel / comp.unix.shell / Is 'cd -' to be considered (in ksh, bash) deprecated for scripting?

SubjectAuthor
* Is 'cd -' to be considered (in ksh, bash) deprecated for scripting?Janis Papanagnou
`* Re: Is 'cd -' to be considered (in ksh, bash) deprecated forKaz Kylheku
 `* Re: Is 'cd -' to be considered (in ksh, bash) deprecated forJanis Papanagnou
  `* Re: Is 'cd -' to be considered (in ksh, bash) deprecated forEli the Bearded
   `* Re: Is 'cd -' to be considered (in ksh, bash) deprecated forJanis Papanagnou
    +* Re: Is 'cd -' to be considered (in ksh, bash) deprecated forKenny McCormack
    |`* Re: Is 'cd -' to be considered (in ksh, bash) deprecated forJanis Papanagnou
    | `* The danger of command line editing (Was: Is 'cd -' to be considered (in ksh, basKenny McCormack
    |  +- Re: The danger of command line editing (Was: Is 'cd -' to beJanis Papanagnou
    |  `- Re: The danger of command line editing (Was: Is 'cd -' to beJanis Papanagnou
    +* Re: Is 'cd -' to be considered (in ksh, bash) deprecated forKaz Kylheku
    |+* Re: Is 'cd -' to be considered (in ksh, bash) deprecated forJanis Papanagnou
    ||`* Re: Is 'cd -' to be considered (in ksh, bash) deprecated forJanis Papanagnou
    || `- Re: Is 'cd -' to be considered (in ksh, bash) deprecated forJanis Papanagnou
    |`* Re: Is 'cd -' to be considered (in ksh, bash) deprecated for scripting?Keith Thompson
    | +- VIM 'cq' command (Was: Is 'cd -' to be considered (in ksh, bash) deprecated for Kenny McCormack
    | `* Re: Is 'cd -' to be considered (in ksh, bash) deprecated forKaz Kylheku
    |  +- VIM's 'cq' command (Was: Is 'cd -' to be considered (in ksh, bash) deprecated foKenny McCormack
    |  `- Re: Is 'cd -' to be considered (in ksh, bash) deprecated for scripting?Keith Thompson
    `* Command line editing mode (was: Is 'cd -' to be considered (in ksh, bash) deprecAxel Reichert
     +- Re: Command line editing mode (was: Is 'cd -' to be considered (in ksh, bash) deKenny McCormack
     +- Re: Command line editing modeKeith Thompson
     +* Re: Command line editing mode (was: Is 'cd -' to be considered (inKaz Kylheku
     |`- Re: Command line editing modeAxel Reichert
     +* Re: Command line editing mode (was: Is 'cd -' to be considered (in ksh, bash) deEli the Bearded
     |+* Re: Command line editing modeAxel Reichert
     ||`* Re: Command line editing modeJanis Papanagnou
     || `- Re: Command line editing modeAxel Reichert
     |`* Re: Command line editing mode (was: Is 'cd -' to be considered (inGeoff Clare
     | +- Re: Command line editing mode (was: Is 'cd -' to be considered (inJalen Q
     | +- Re: Command line editing mode (was: Is 'cd -' to be considered (inJalen Q
     | `* Re: Command line editing mode (was: Is 'cd -' to be considered (inJalen Q
     |  `* Re: Command line editing mode (was: Is 'cd -' to be considered (inJalen Q
     |   `- Re: Command line editing mode (was: Is 'cd -' to be considered (inJalen Q
     +* Re: Command line editing modeJanis Papanagnou
     |`* [OT] Vi-editor-modes in [ksh] vi-mode editing (was Re: Command lineJanis Papanagnou
     | `* Re: [OT] Vi-editor-modes in [ksh] vi-mode editing (was Re: Command line editing Spiros Bousbouras
     |  +- Re: [OT] Vi-editor-modes in [ksh] vi-mode editing (was Re: CommandJanis Papanagnou
     |  +* Re: [OT] Vi-editor-modes in [ksh] vi-mode editing (was Re: CommandJanis Papanagnou
     |  |`- Re: [OT] Vi-editor-modes in [ksh] vi-mode editing (was Re: CommandAragorn
     |  `- Re: [OT] Vi-editor-modes in [ksh] vi-mode editing (was Re: CommandGeoff Clare
     +* Re: Command line editing modeSpiros Bousbouras
     |+* Re: Command line editing modeBrian Patrie
     ||`- Re: Command line editing modeSpiros Bousbouras
     |+- Thanks for all the feedback! (was: Command line editing mode)Axel Reichert
     |`* Re: Command line editing modeChristian Weisgerber
     | +- Re: Command line editing modeKaz Kylheku
     | `- Re: Command line editing modeKeith Thompson
     `* Re: Command line editing mode (was: Is 'cd -' to be considered (inBit Twister
      `* Re: Command line editing mode (was: Is 'cd -' to be considered (inAragorn
       `* Re: Command line editing modeKeith Thompson
        +* Re: Command line editing modeAragorn
        |`- Re: Command line editing modeKeith Thompson
        `- Re: Command line editing modeJanis Papanagnou

Pages:123
Is 'cd -' to be considered (in ksh, bash) deprecated for scripting?

<tjhrk0$37g49$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5772&group=comp.unix.shell#5772

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Is 'cd -' to be considered (in ksh, bash) deprecated for scripting?
Date: Sat, 29 Oct 2022 02:20:15 +0200
Organization: A noiseless patient Spider
Lines: 19
Message-ID: <tjhrk0$37g49$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 29 Oct 2022 00:20:16 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="8ae27c98925627cabf09e53a150784ef";
logging-data="3391625"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Oxp852ZpaQg7qAciUUMvT"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:Htc2bV8+atVUPUsXRwV+Of6pM+I=
X-Mozilla-News-Host: news://news.eternal-september.org:119
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Sat, 29 Oct 2022 00:20 UTC

It just occurred to me that 'cd -' with its _special behavior_ seems
not well suited for scripting. While 'cd anydir' is just doing its
job and switches to the directory 'cd -' will create spurious output;
the target directory. While that may be desirable in interactive use
I don't see a point to create that spurious output in scripting.
Neither 'cd "$OLDPWD"' nor 'cd ~-' will do that (because they imply
an expansion).

Bash and Ksh always produce that unnecessary output with 'cd -' while
Zsh does that, more sensibly, it seems, only in _interactive mode_.

Is there any sensible application for that inconsistency in scripts?
I mean, say, something like here_I_am=$( cd - )
(which I'd rather explicitly ask for if I want to know the 'pwd').

I am using 'cd -' for decades but now its output got in the way of
other output I create - strange that it didn't occur to me before.

Janis

Re: Is 'cd -' to be considered (in ksh, bash) deprecated for scripting?

<20221028182456.668@kylheku.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5773&group=comp.unix.shell#5773

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: 864-117-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.unix.shell
Subject: Re: Is 'cd -' to be considered (in ksh, bash) deprecated for
scripting?
Date: Sat, 29 Oct 2022 01:38:24 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 40
Message-ID: <20221028182456.668@kylheku.com>
References: <tjhrk0$37g49$1@dont-email.me>
Injection-Date: Sat, 29 Oct 2022 01:38:24 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="620a729e799e1a050f133c50a54826b0";
logging-data="3501095"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX184s3NJHglSaAUMQsC1jFJdql/a/tmoDKA="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:shH4T/edBCpnpBwRdh1PwIbpf4Q=
 by: Kaz Kylheku - Sat, 29 Oct 2022 01:38 UTC

On 2022-10-29, Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
> It just occurred to me that 'cd -' with its _special behavior_ seems
> not well suited for scripting. While 'cd anydir' is just doing its
> job and switches to the directory 'cd -' will create spurious output;
> the target directory. While that may be desirable in interactive use
> I don't see a point to create that spurious output in scripting.
> Neither 'cd "$OLDPWD"' nor 'cd ~-' will do that (because they imply
> an expansion).

Hey look, this is required by POSIX!

When a <hyphen-minus> is used as the operand, this shall be
equivalent to the command:

cd "$OLDPWD" && pwd

which changes to the previous working directory and then writes its
name.

POSIX doesn't say that it may behave differently in a noninteractive
script, so shells which change the behavior are nonconforming.

Basically it seems to be a shortcut for interactive use;
take me back to where I was before and remind me where that is.

It probably suited someone's personal workflows and tastes, and
that person got it into the cd command.

If you don't have the current working directory embedded into
your prompt, and execute "cd -" several times, you might know
know where you are. You can use pwd; but then that's just what is
built-in to the cd - semantics.

Maybe this comes from a time when it wasn't fashionable to adjust the
prompt to include the current directory.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal

Re: Is 'cd -' to be considered (in ksh, bash) deprecated for scripting?

<tjiu05$3e9u7$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5774&group=comp.unix.shell#5774

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Is 'cd -' to be considered (in ksh, bash) deprecated for
scripting?
Date: Sat, 29 Oct 2022 12:07:00 +0200
Organization: A noiseless patient Spider
Lines: 62
Message-ID: <tjiu05$3e9u7$1@dont-email.me>
References: <tjhrk0$37g49$1@dont-email.me> <20221028182456.668@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 29 Oct 2022 10:07:01 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="67d70caa86fef6de31dc0ca0de8612dd";
logging-data="3614663"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+6m7Q/XVtj1mkB1xECROin"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:lT6/zo5GLxPi0b6b9r+2feKe7RA=
X-Enigmail-Draft-Status: N1110
In-Reply-To: <20221028182456.668@kylheku.com>
 by: Janis Papanagnou - Sat, 29 Oct 2022 10:07 UTC

On 29.10.2022 03:38, Kaz Kylheku wrote:
> On 2022-10-29, Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
>> It just occurred to me that 'cd -' with its _special behavior_ seems
>> not well suited for scripting. While 'cd anydir' is just doing its
>> job and switches to the directory 'cd -' will create spurious output;
>> the target directory. While that may be desirable in interactive use
>> I don't see a point to create that spurious output in scripting.
>> Neither 'cd "$OLDPWD"' nor 'cd ~-' will do that (because they imply
>> an expansion).
>
> Hey look, this is required by POSIX!

Oh, I haven't looked at POSIX; I was somehow assuming that it's a
non-standardized ksh/bash/zsh extension of 'cd' (but confused that
maybe with the 'cd oldstring newstring' extension?). Looking that
up in the portability section of Bolsky/Korn I see both listed in
the "Ksh features not in POSIX" section. So 'cd -' seems to be a
more recent addition to POSIX. We probably have to blame the ksh
paragon for the way this functionality got standardized in POSIX.

>
> When a <hyphen-minus> is used as the operand, this shall be
> equivalent to the command:
>
> cd "$OLDPWD" && pwd
>
> which changes to the previous working directory and then writes its
> name.
>
> POSIX doesn't say that it may behave differently in a noninteractive
> script, so shells which change the behavior are nonconforming.
>
> Basically it seems to be a shortcut for interactive use;
> take me back to where I was before and remind me where that is.

Indeed. - Too bad that they didn't differentiate [in ksh] at that
time between interactive mode and scripting in case of 'cd'.

>
> It probably suited someone's personal workflows and tastes, and
> that person got it into the cd command.
>
> If you don't have the current working directory embedded into
> your prompt, and execute "cd -" several times, you might know
> know where you are. You can use pwd; but then that's just what is
> built-in to the cd - semantics.

Personally I can't remember what files are actually in a directory,
so every 'cd' should probably imply a 'ls'. :-)

>
> Maybe this comes from a time when it wasn't fashionable to adjust the
> prompt to include the current directory.

Even then I wouldn't need it, but as you say, personal workflows
and preferences vary.

I seem to recall that adjusting the prompt was common even in the
late 1980's (my csh times), but memories are faint.

Janis

Re: Is 'cd -' to be considered (in ksh, bash) deprecated for scripting?

<eli$2210291718@qaz.wtf>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5775&group=comp.unix.shell#5775

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!.POSTED.panix5.panix.com!qz!not-for-mail
From: *...@eli.users.panix.com (Eli the Bearded)
Newsgroups: comp.unix.shell
Subject: Re: Is 'cd -' to be considered (in ksh, bash) deprecated for
scripting?
Date: Sat, 29 Oct 2022 21:27:08 -0000 (UTC)
Organization: Some absurd concept
Message-ID: <eli$2210291718@qaz.wtf>
References: <tjhrk0$37g49$1@dont-email.me> <20221028182456.668@kylheku.com> <tjiu05$3e9u7$1@dont-email.me>
Injection-Date: Sat, 29 Oct 2022 21:27:08 -0000 (UTC)
Injection-Info: reader2.panix.com; posting-host="panix5.panix.com:166.84.1.5";
logging-data="10431"; mail-complaints-to="abuse@panix.com"
User-Agent: Vectrex rn 2.1 (beta)
X-Liz: It's actually happened, the entire Internet is a massive game of Redcode
X-Motto: "Erosion of rights never seems to reverse itself." -- kenny@panix
X-US-Congress: Moronic Fucks.
X-Attribution: EtB
XFrom: is a real address
Encrypted: double rot-13
 by: Eli the Bearded - Sat, 29 Oct 2022 21:27 UTC

In comp.unix.shell, Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
> On 29.10.2022 03:38, Kaz Kylheku wrote:
>> Hey look, this is required by POSIX!

Really making me want to 'mkdir ./-' and see how things react.

> Personally I can't remember what files are actually in a directory,
> so every 'cd' should probably imply a 'ls'. :-)

I have some directories where that's painful. Even if using the don't
sort flag.

>> Maybe this comes from a time when it wasn't fashionable to adjust the
>> prompt to include the current directory.
> I seem to recall that adjusting the prompt was common even in the
> late 1980's (my csh times), but memories are faint.

It's behavior I abhor. Prompt changing for 'su', sure; changing with
exit code of last process, okay; putting history line number in, maybe;,
but directories? Ugh, it changes the length of the prompt too much.

But yeah, some people have apparently liked that for a long time.

Elijah
------
PS1=": $USER@$HOST ; "; PS2='^I'

Re: Is 'cd -' to be considered (in ksh, bash) deprecated for scripting?

<tjk805$3ndt9$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5776&group=comp.unix.shell#5776

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!paganini.bofh.team!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Is 'cd -' to be considered (in ksh, bash) deprecated for
scripting?
Date: Sun, 30 Oct 2022 00:03:49 +0200
Organization: A noiseless patient Spider
Lines: 36
Message-ID: <tjk805$3ndt9$1@dont-email.me>
References: <tjhrk0$37g49$1@dont-email.me> <20221028182456.668@kylheku.com>
<tjiu05$3e9u7$1@dont-email.me> <eli$2210291718@qaz.wtf>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 29 Oct 2022 22:03:49 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="8c6093ddb461745ba25ec92c698cf5af";
logging-data="3913641"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Y897w+OYLqo75K2u3hK0j"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:4iPRsa1xTJnv1MTPp70oQ11dNTY=
X-Enigmail-Draft-Status: N1110
In-Reply-To: <eli$2210291718@qaz.wtf>
 by: Janis Papanagnou - Sat, 29 Oct 2022 22:03 UTC

On 29.10.2022 23:27, Eli the Bearded wrote:
>> On 29.10.2022 03:38, Kaz Kylheku wrote:
>>> [ adjust the prompt to include the current directory ]
>
> It's behavior I abhor. Prompt changing for 'su', sure; changing with
> exit code of last process, okay; putting history line number in, maybe;,
> but directories? Ugh, it changes the length of the prompt too much.

That's why you occasionally see folks using such prompts with
embedded line breaks, I suppose, having the path on a separate
line, so that you have a complete line available for input.

Myself I haven't changed my prompt definition for decades. It's
still something like user@host:path where the path prefix is
substituted by a '~' for files beneath $HOME. The user@host part
I'd consider less useful in the private context where I solely
work on a single Unix system now. So if I decide to change the
prompt definition I probably start removing that user@host first.

The length of the prompt isn't an issue for me, though. Whenever
a command gets typed that is getting lengthy (or use an inherently
long compound command) I just "Esc v" and get a vi instance where
I can continue typing any command with arbitrary complexity.[*]
(This is in Kornshell with vi editing mode activated.)

What I recently added is a shell-level counter to see whether I
started another (embedded) instance, e.g. from a shell escape of
programs that support that.

Janis

[*] Something I consider an issue here is that if I abort editing
with :q! the typed command will still get executed, so it needs
to be deleted before quitting or prefixed by '#'. My expectation
here would be that :w should execute the entered text and :q! not.

Re: Is 'cd -' to be considered (in ksh, bash) deprecated for scripting?

<tjk8ef$3ch0q$1@news.xmission.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5777&group=comp.unix.shell#5777

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gaze...@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: Re: Is 'cd -' to be considered (in ksh, bash) deprecated for
scripting?
Date: Sat, 29 Oct 2022 22:11:27 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <tjk8ef$3ch0q$1@news.xmission.com>
References: <tjhrk0$37g49$1@dont-email.me> <tjiu05$3e9u7$1@dont-email.me> <eli$2210291718@qaz.wtf> <tjk805$3ndt9$1@dont-email.me>
Injection-Date: Sat, 29 Oct 2022 22:11:27 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="3556378"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Sat, 29 Oct 2022 22:11 UTC

In article <tjk805$3ndt9$1@dont-email.me>,
Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
....
>[*] Something I consider an issue here is that if I abort editing
>with :q! the typed command will still get executed, so it needs
>to be deleted before quitting or prefixed by '#'. My expectation
>here would be that :w should execute the entered text and :q! not.

Yeah, I find this a little annoying too. But, of course, it makes perfect
sense when you think about it. :q!'ing out just reverts the file to what
it was on entry (or at last save, if any).

I've gotten in the habit of doing dd (assuming just a single line in the
buffer) before exiting (if I don't want anything to be executed).

--
The whole aim of practical politics is to keep the populace alarmed (and hence clamorous
to be led to safety) by menacing it with an endless series of hobgoblins, all of them imaginary.

H. L. Mencken

Re: Is 'cd -' to be considered (in ksh, bash) deprecated for scripting?

<tjm0oh$6g1a$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5778&group=comp.unix.shell#5778

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Is 'cd -' to be considered (in ksh, bash) deprecated for
scripting?
Date: Sun, 30 Oct 2022 15:12:33 +0100
Organization: A noiseless patient Spider
Lines: 46
Message-ID: <tjm0oh$6g1a$1@dont-email.me>
References: <tjhrk0$37g49$1@dont-email.me> <tjiu05$3e9u7$1@dont-email.me>
<eli$2210291718@qaz.wtf> <tjk805$3ndt9$1@dont-email.me>
<tjk8ef$3ch0q$1@news.xmission.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 30 Oct 2022 14:12:33 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="9cb24856d1517e0e8186382b61288367";
logging-data="213034"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/ile7rTqsKw2KytpK84JKF"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:4WASARPF6rx3lbddlZs0rWVYrBA=
X-Enigmail-Draft-Status: N1110
In-Reply-To: <tjk8ef$3ch0q$1@news.xmission.com>
 by: Janis Papanagnou - Sun, 30 Oct 2022 14:12 UTC

On 30.10.2022 00:11, Kenny McCormack wrote:
> In article <tjk805$3ndt9$1@dont-email.me>,
> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
> ...
>> [*] Something I consider an issue here is that if I abort editing
>> with :q! the typed command will still get executed, so it needs
>> to be deleted before quitting or prefixed by '#'. My expectation
>> here would be that :w should execute the entered text and :q! not.
>
> Yeah, I find this a little annoying too. But, of course, it makes perfect
> sense when you think about it. :q!'ing out just reverts the file to what
> it was on entry (or at last save, if any).

Yes, technically you are correct. What I had in mind was that the shell
may have more options to implement something more sensible (read it as:
something that I think would be more sensible). It seems that the vi(m)
instance will not create exit codes !=0 to differentiate that, though.
So shell might resort to date of "creation" (i.e. first modification)
and modification date after the edit to determine tmp-file changes.

I am aware (OTOH) that some folks may have the expectation to execute
at least the initial text sequence if any other command modification
gets :quited, but to me that appears extremely risky. (Thinking of a
start with rm -rf * then realizing to add a cd command before the rm
and then quitting the editing.)

Besides editing the newly typed command we can use "Esc v" also to
edit (simple or compound) commands from the history. In case of a
complex command (from history or newly typed) deletion is a bit more
cumbersome.

Besides command line editing (vi/emacs) in shell there's also the stty
setting 'kill' to allow erasing the input typed on the line; but that
doesn't work in vi mode. There should be *some way* to _abort_ sending
the text as command to the shell. (Explicitly deleting everything seems
counter-intuitive to me.)

>
> I've gotten in the habit of doing dd (assuming just a single line in the
> buffer) before exiting (if I don't want anything to be executed).

Yes, either that, or, (if the typed command will have no bad effects)
just accept the error message.

Janis

The danger of command line editing (Was: Is 'cd -' to be considered (in ksh, bash) deprecated for) scripting?

<tjm1nn$3ddf4$1@news.xmission.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5779&group=comp.unix.shell#5779

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gaze...@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: The danger of command line editing (Was: Is 'cd -' to be considered (in ksh, bash) deprecated for)
scripting?
Date: Sun, 30 Oct 2022 14:29:11 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <tjm1nn$3ddf4$1@news.xmission.com>
References: <tjhrk0$37g49$1@dont-email.me> <tjk805$3ndt9$1@dont-email.me> <tjk8ef$3ch0q$1@news.xmission.com> <tjm0oh$6g1a$1@dont-email.me>
Injection-Date: Sun, 30 Oct 2022 14:29:11 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="3585508"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Sun, 30 Oct 2022 14:29 UTC

In article <tjm0oh$6g1a$1@dont-email.me>,
Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
....
>> I've gotten in the habit of doing dd (assuming just a single line in the
>> buffer) before exiting (if I don't want anything to be executed).
>
>Yes, either that, or, (if the typed command will have no bad effects)
>just accept the error message.

Maybe it should be possible to configure the shell to always ask for
confirmation (i.e., an "Are you sure?" prompt) before going ahead after you
exit the editor.

Incidentally, I agree that the best solution would be if vi (which is
usually vim these days) could return some non-zero exit code in this
situation. I'll bet that could be done with some fancy vim scripting;
whether it would be worth the trouble or not is another matter.

It would be interesting to know if the shell would recognize the non-zero
exit code and do the right thing. I'll have to test that at some point (in
bash).

--
I'm building a wall.

Re: The danger of command line editing (Was: Is 'cd -' to be considered (in ksh, bash) deprecated for) scripting?

<tjn37j$ab9l$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5780&group=comp.unix.shell#5780

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!paganini.bofh.team!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: The danger of command line editing (Was: Is 'cd -' to be
considered (in ksh, bash) deprecated for) scripting?
Date: Mon, 31 Oct 2022 01:00:50 +0100
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <tjn37j$ab9l$1@dont-email.me>
References: <tjhrk0$37g49$1@dont-email.me> <tjk805$3ndt9$1@dont-email.me>
<tjk8ef$3ch0q$1@news.xmission.com> <tjm0oh$6g1a$1@dont-email.me>
<tjm1nn$3ddf4$1@news.xmission.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 31 Oct 2022 00:00:51 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="b44d4d0d0351a8bce38f0722bbffae3c";
logging-data="339253"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1//PV/oa4DQolsg7VtigvTh"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:bO5EljIesNQ0/i7DKzTZRUlhNMQ=
X-Enigmail-Draft-Status: N1110
In-Reply-To: <tjm1nn$3ddf4$1@news.xmission.com>
 by: Janis Papanagnou - Mon, 31 Oct 2022 00:00 UTC

On 30.10.2022 15:29, Kenny McCormack wrote:
>
> Incidentally, I agree that the best solution would be if vi (which is
> usually vim these days) could return some non-zero exit code in this
> situation. I'll bet that could be done with some fancy vim scripting;
> whether it would be worth the trouble or not is another matter.

The problem I see is that we'd be creating sort of an own ecosystem
with modified tools and tools relying on such modification.

>
> It would be interesting to know if the shell would recognize the non-zero
> exit code and do the right thing. I'll have to test that at some point (in
> bash).

I wouldn't expect that shell would react on non-zero status here,
but please keep us informed, in any case it's interesting to know.

Janis

Re: Is 'cd -' to be considered (in ksh, bash) deprecated for scripting?

<20221031000940.53@kylheku.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5781&group=comp.unix.shell#5781

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: 864-117-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.unix.shell
Subject: Re: Is 'cd -' to be considered (in ksh, bash) deprecated for
scripting?
Date: Mon, 31 Oct 2022 07:28:58 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 40
Message-ID: <20221031000940.53@kylheku.com>
References: <tjhrk0$37g49$1@dont-email.me> <20221028182456.668@kylheku.com>
<tjiu05$3e9u7$1@dont-email.me> <eli$2210291718@qaz.wtf>
<tjk805$3ndt9$1@dont-email.me>
Injection-Date: Mon, 31 Oct 2022 07:28:58 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="6af8c41a8cf0d8689c329ae383c75024";
logging-data="487521"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18Mcjf0Dn3kqWlTt+WXu24RhbIe3Zv/Teo="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:vLFKDdaLaTGA/WFAl8owqAanV24=
 by: Kaz Kylheku - Mon, 31 Oct 2022 07:28 UTC

On 2022-10-29, Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:

> [*] Something I consider an issue here is that if I abort editing
> with :q! the typed command will still get executed, so it needs
> to be deleted before quitting or prefixed by '#'. My expectation
> here would be that :w should execute the entered text and :q! not.

You get used to that from version control. Whether you're using
old cvs or git, when you find yourself making a commit you don't
want, you blank out the commit log message and save it, and
then quit.

git will not commit if the editor terminates abnormally.

You get a mesage like

error: There was a problem with the editor 'vim'.
Please supply the message using either -m or -F option

Bash has two features for editing a command in an external editor:

- fc (fix command) to edit the previous command (or a range
of commands).

- Ctrl-x e to switch the current command line edit to an
external editor.

Under both of these, the command will be dispatched if you
save and exit.

Like git, they are robust to bad termination. If you suspend
the editor and terminate it with "kill -KILL", Bash will
not execute the command.

If Vim had a way to exit unsuccessfully, as Kenny wishes,
at least git and Bash will do the right thing.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal

Re: The danger of command line editing (Was: Is 'cd -' to be considered (in ksh, bash) deprecated for) scripting?

<tjo5p3$fihd$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5782&group=comp.unix.shell#5782

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: The danger of command line editing (Was: Is 'cd -' to be
considered (in ksh, bash) deprecated for) scripting?
Date: Mon, 31 Oct 2022 10:50:27 +0100
Organization: A noiseless patient Spider
Lines: 19
Message-ID: <tjo5p3$fihd$1@dont-email.me>
References: <tjhrk0$37g49$1@dont-email.me> <tjk805$3ndt9$1@dont-email.me>
<tjk8ef$3ch0q$1@news.xmission.com> <tjm0oh$6g1a$1@dont-email.me>
<tjm1nn$3ddf4$1@news.xmission.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 31 Oct 2022 09:50:27 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="ec0586be4a431d372fc26d3494f1b53f";
logging-data="510509"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/LADIesTB25bGTTeVvp22X"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:QiHCRMDPwbCBb20Vq6PFMDdvmh4=
In-Reply-To: <tjm1nn$3ddf4$1@news.xmission.com>
 by: Janis Papanagnou - Mon, 31 Oct 2022 09:50 UTC

On 30.10.2022 15:29, Kenny McCormack wrote:
>
> Incidentally, I agree that the best solution would be if vi (which is
> usually vim these days) could return some non-zero exit code in this
> situation. I'll bet that could be done with some fancy vim scripting;
> whether it would be worth the trouble or not is another matter.
>
> It would be interesting to know if the shell would recognize the non-zero
> exit code and do the right thing. I'll have to test that at some point (in
> bash).

The "Esc v" in Kornshell's vi editing mode is referring to 'fc -e vi'
and the 'fc' man page says:

"[...] If the editor returns a non-zero exit status, this will suppress
the entry into the history list and the command reexecution. [...]"

Janis

Re: Is 'cd -' to be considered (in ksh, bash) deprecated for scripting?

<tjo90j$fq8e$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5783&group=comp.unix.shell#5783

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Is 'cd -' to be considered (in ksh, bash) deprecated for
scripting?
Date: Mon, 31 Oct 2022 11:45:39 +0100
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <tjo90j$fq8e$1@dont-email.me>
References: <tjhrk0$37g49$1@dont-email.me> <20221028182456.668@kylheku.com>
<tjiu05$3e9u7$1@dont-email.me> <eli$2210291718@qaz.wtf>
<tjk805$3ndt9$1@dont-email.me> <20221031000940.53@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 31 Oct 2022 10:45:39 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="ec0586be4a431d372fc26d3494f1b53f";
logging-data="518414"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19HAk8S+zdOnk4jBS5TRqaO"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:weSG9kE5qq7lvrMMS9obaIMixBQ=
In-Reply-To: <20221031000940.53@kylheku.com>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Mon, 31 Oct 2022 10:45 UTC

On 31.10.2022 08:28, Kaz Kylheku wrote:
> On 2022-10-29, Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
>
>> [*] Something I consider an issue here is that if I abort editing
>> with :q! the typed command will still get executed, so it needs
>> to be deleted before quitting or prefixed by '#'. My expectation
>> here would be that :w should execute the entered text and :q! not.
>
> If Vim had a way to exit unsuccessfully, as Kenny wishes,
> at least git and Bash will do the right thing.

....or, if an unsuccessful exit is not supported by vim, use a
wrapper - ideally only for shell history edits, so that you can
keep the wrapper simple - like this fragment to create an error
status depending on an actual file change

before=$( stat -c%Y "$1" ) # or %y for higher accuracy?
vim "$1"
after=$( stat -c%Y "$1" )
[[ "$before" != "$after" ]]

and setting 'VISUAL' to such a wrapper.

Do other commands evaluate the 'VISUAL' shell variable?

Janis

Re: Is 'cd -' to be considered (in ksh, bash) deprecated for scripting?

<tjo9b9$fr8l$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5784&group=comp.unix.shell#5784

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Is 'cd -' to be considered (in ksh, bash) deprecated for
scripting?
Date: Mon, 31 Oct 2022 11:51:21 +0100
Organization: A noiseless patient Spider
Lines: 34
Message-ID: <tjo9b9$fr8l$1@dont-email.me>
References: <tjhrk0$37g49$1@dont-email.me> <20221028182456.668@kylheku.com>
<tjiu05$3e9u7$1@dont-email.me> <eli$2210291718@qaz.wtf>
<tjk805$3ndt9$1@dont-email.me> <20221031000940.53@kylheku.com>
<tjo90j$fq8e$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 31 Oct 2022 10:51:21 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="ec0586be4a431d372fc26d3494f1b53f";
logging-data="519445"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/e5O2d3+aRAvntdhwqkfP0"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:U0mb1VkqtsPVpjtJp2G3YWGatnA=
In-Reply-To: <tjo90j$fq8e$1@dont-email.me>
 by: Janis Papanagnou - Mon, 31 Oct 2022 10:51 UTC

On 31.10.2022 11:45, Janis Papanagnou wrote:
> On 31.10.2022 08:28, Kaz Kylheku wrote:
>> On 2022-10-29, Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
>>
>>> [*] Something I consider an issue here is that if I abort editing
>>> with :q! the typed command will still get executed, so it needs
>>> to be deleted before quitting or prefixed by '#'. My expectation
>>> here would be that :w should execute the entered text and :q! not.
>>
>> If Vim had a way to exit unsuccessfully, as Kenny wishes,
>> at least git and Bash will do the right thing.
>
> ...or, if an unsuccessful exit is not supported by vim, use a
> wrapper - ideally only for shell history edits, so that you can
> keep the wrapper simple - like this fragment to create an error
> status depending on an actual file change
>
> before=$( stat -c%Y "$1" ) # or %y for higher accuracy?
> vim "$1"
> after=$( stat -c%Y "$1" )
> [[ "$before" != "$after" ]]
>
> and setting 'VISUAL' to such a wrapper.

It just occurred to me that there's also the 'HISTEDIT' (and the
obsolete 'FCEDIT') variable to define the editor. Using one of
these would reduce the risk to be used by other commands.

>
> Do other commands evaluate the 'VISUAL' shell variable?
>
> Janis
>

Re: Is 'cd -' to be considered (in ksh, bash) deprecated for scripting?

<tjo9la$ftdf$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5785&group=comp.unix.shell#5785

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Is 'cd -' to be considered (in ksh, bash) deprecated for
scripting?
Date: Mon, 31 Oct 2022 11:56:42 +0100
Organization: A noiseless patient Spider
Lines: 40
Message-ID: <tjo9la$ftdf$1@dont-email.me>
References: <tjhrk0$37g49$1@dont-email.me> <20221028182456.668@kylheku.com>
<tjiu05$3e9u7$1@dont-email.me> <eli$2210291718@qaz.wtf>
<tjk805$3ndt9$1@dont-email.me> <20221031000940.53@kylheku.com>
<tjo90j$fq8e$1@dont-email.me> <tjo9b9$fr8l$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 31 Oct 2022 10:56:42 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="ec0586be4a431d372fc26d3494f1b53f";
logging-data="521647"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+uH+6GVdzzX+AxyeqIu2qP"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:yLKpQ4IYYtxpY3a/HWPCo/UfMEY=
In-Reply-To: <tjo9b9$fr8l$1@dont-email.me>
 by: Janis Papanagnou - Mon, 31 Oct 2022 10:56 UTC

On 31.10.2022 11:51, Janis Papanagnou wrote:
> On 31.10.2022 11:45, Janis Papanagnou wrote:
>> On 31.10.2022 08:28, Kaz Kylheku wrote:
>>> On 2022-10-29, Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
>>>
>>>> [*] Something I consider an issue here is that if I abort editing
>>>> with :q! the typed command will still get executed, so it needs
>>>> to be deleted before quitting or prefixed by '#'. My expectation
>>>> here would be that :w should execute the entered text and :q! not.
>>>
>>> If Vim had a way to exit unsuccessfully, as Kenny wishes,
>>> at least git and Bash will do the right thing.
>>
>> ...or, if an unsuccessful exit is not supported by vim, use a
>> wrapper - ideally only for shell history edits, so that you can
>> keep the wrapper simple - like this fragment to create an error
>> status depending on an actual file change
>>
>> before=$( stat -c%Y "$1" ) # or %y for higher accuracy?
>> vim "$1"
>> after=$( stat -c%Y "$1" )
>> [[ "$before" != "$after" ]]
>>
>> and setting 'VISUAL' to such a wrapper.
>
> It just occurred to me that there's also the 'HISTEDIT' (and the
> obsolete 'FCEDIT') variable to define the editor. Using one of
> these would reduce the risk to be used by other commands.

Just tested that. The wrapper works with 'VISUAL' but not with the
other two variables.

>
>>
>> Do other commands evaluate the 'VISUAL' shell variable?
>>
>> Janis
>>
>

Re: Is 'cd -' to be considered (in ksh, bash) deprecated for scripting?

<87v8o0m499.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5786&group=comp.unix.shell#5786

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.unix.shell
Subject: Re: Is 'cd -' to be considered (in ksh, bash) deprecated for scripting?
Date: Mon, 31 Oct 2022 07:55:46 -0700
Organization: None to speak of
Lines: 15
Message-ID: <87v8o0m499.fsf@nosuchdomain.example.com>
References: <tjhrk0$37g49$1@dont-email.me> <20221028182456.668@kylheku.com>
<tjiu05$3e9u7$1@dont-email.me> <eli$2210291718@qaz.wtf>
<tjk805$3ndt9$1@dont-email.me> <20221031000940.53@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: reader01.eternal-september.org; posting-host="61b7f010b101070df5e3c2047a1715fc";
logging-data="558789"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX196NtSvPqOtd04gWTFSEtiS"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:LWHMStFSodh3V7EhkDr5zBkiBnc=
sha1:nwjYfs1qJLvab9NSxdoHkeSQjN8=
 by: Keith Thompson - Mon, 31 Oct 2022 14:55 UTC

Kaz Kylheku <864-117-4973@kylheku.com> writes:
> If Vim had a way to exit unsuccessfully, [...]
> at least git and Bash will do the right thing.

It does.

":cq" or ":cquit" exit with a status of 1. It takes an optional
argument to specify a non-zero status (including 0).

":help cq" to see the documentation.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
[Watch this space]
void Void(void) { Void(); } /* The recursive call of the void */

VIM 'cq' command (Was: Is 'cd -' to be considered (in ksh, bash) deprecated for scripting?)

<tjoor9$3eqou$1@news.xmission.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5787&group=comp.unix.shell#5787

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gaze...@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: VIM 'cq' command (Was: Is 'cd -' to be considered (in ksh, bash) deprecated for scripting?)
Date: Mon, 31 Oct 2022 15:15:53 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <tjoor9$3eqou$1@news.xmission.com>
References: <tjhrk0$37g49$1@dont-email.me> <tjk805$3ndt9$1@dont-email.me> <20221031000940.53@kylheku.com> <87v8o0m499.fsf@nosuchdomain.example.com>
Injection-Date: Mon, 31 Oct 2022 15:15:53 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="3631902"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Mon, 31 Oct 2022 15:15 UTC

In article <87v8o0m499.fsf@nosuchdomain.example.com>,
>> If Vim had a way to exit unsuccessfully, [...]
>> at least git and Bash will do the right thing.
>
>It does.
>
>":cq" or ":cquit" exit with a status of 1. It takes an optional
>argument to specify a non-zero status (including 0).
>
>":help cq" to see the documentation.

That's very useful. Thank you.
I can think of many occasions where this would be useful.

Of course, it has to be used with caution, but when it's right, it's right.

--
The randomly chosen signature file that would have appeared here is more than 4
lines long. As such, it violates one or more Usenet RFCs. In order to remain
in compliance with said RFCs, the actual sig can be found at the following URL:
http://user.xmission.com/~gazelle/Sigs/CLCtopics

Re: Is 'cd -' to be considered (in ksh, bash) deprecated for scripting?

<20221031092259.353@kylheku.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5788&group=comp.unix.shell#5788

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: 864-117-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.unix.shell
Subject: Re: Is 'cd -' to be considered (in ksh, bash) deprecated for
scripting?
Date: Mon, 31 Oct 2022 16:47:45 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 41
Message-ID: <20221031092259.353@kylheku.com>
References: <tjhrk0$37g49$1@dont-email.me> <20221028182456.668@kylheku.com>
<tjiu05$3e9u7$1@dont-email.me> <eli$2210291718@qaz.wtf>
<tjk805$3ndt9$1@dont-email.me> <20221031000940.53@kylheku.com>
<87v8o0m499.fsf@nosuchdomain.example.com>
Injection-Date: Mon, 31 Oct 2022 16:47:45 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="6af8c41a8cf0d8689c329ae383c75024";
logging-data="577625"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Lw+eGVVyHIlu3cbbPuVEU9vamVGKSODQ="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:hydMV1qAU+Asn78h+7y8bc8hUcc=
 by: Kaz Kylheku - Mon, 31 Oct 2022 16:47 UTC

On 2022-10-31, Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
> Kaz Kylheku <864-117-4973@kylheku.com> writes:
>> If Vim had a way to exit unsuccessfully, [...]
>> at least git and Bash will do the right thing.
>
> It does.
>
> ":cq" or ":cquit" exit with a status of 1.

Wow, that is buried in the functionality.

I've never heard of the use case hinted at by the documentation, with
regard to the compilation scenario: that if you quit with a failed
status, the compiler won't try to compile that file again.

The idea must be that vim is in some kind of external loop
invoked during a build to fix files with errors. To break out of that
loop, you use :cq. Somethingg like:

# while compilation fails, but editing doesn't, repeat:

while ! $(CC) $< -o $@ && vim $@ ; do : ; done

Except with a bit more complexity to invoke vim on the error
output captured from the compiler as a quickfix list. (which is why
this cq is buried in the quickfix command suite).

This seems worth looking into because it has certain obvious advantages
over iterating on "make -k" and fixing batches of errors:

> It takes an optional
> argument to specify a non-zero status (including 0).
>
> ":help cq" to see the documentation.

The argument must be in newer Vim versions; none is documented for Vim
8.0, and it rejects arguments or prefixes.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal

VIM's 'cq' command (Was: Is 'cd -' to be considered (in ksh, bash) deprecated for) scripting?

<tjovgq$3estf$1@news.xmission.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5789&group=comp.unix.shell#5789

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gaze...@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: VIM's 'cq' command (Was: Is 'cd -' to be considered (in ksh, bash) deprecated for)
scripting?
Date: Mon, 31 Oct 2022 17:09:46 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <tjovgq$3estf$1@news.xmission.com>
References: <tjhrk0$37g49$1@dont-email.me> <20221031000940.53@kylheku.com> <87v8o0m499.fsf@nosuchdomain.example.com> <20221031092259.353@kylheku.com>
Injection-Date: Mon, 31 Oct 2022 17:09:46 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="3634095"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Mon, 31 Oct 2022 17:09 UTC

In article <20221031092259.353@kylheku.com>,
....
>> It takes an optional
>> argument to specify a non-zero status (including 0).
>>
>> ":help cq" to see the documentation.
>
>The argument must be in newer Vim versions; none is documented for Vim
>8.0, and it rejects arguments or prefixes.

Yes. My Vim 7.4 is the same. 'cq' is there, but the N option isn't.

However, in Vim 9.0.180, the help says:

:cq[uit][!]
:{N}cq[uit][!]
:cq[uit][!] {N} Quit Vim with error code {N}. {N} defaults to one.
Useful when Vim is called from another program:
e.g., a compiler will not compile the same file again,
`git commit` will abort the committing process, `fc`
(built-in for shells like bash and zsh) will not
execute the command, etc.
{N} can also be zero, in which case Vim exits
normally.
WARNING: All changes in files are lost! Also when the
[!] is not used. It works like ":qall!" |:qall|,
except that Vim returns a non-zero exit code.

What is funny is that the ! seems to be a no-op; it does exactly the same
thing with or without the !. Why mention it at all?

--
(Cruz certainly has an odd face) ... it looks like someone sewed pieces of a
waterlogged Reagan mask together at gunpoint ...

http://www.rollingstone.com/politics/news/how-america-made-donald-trump-unstoppable-20160224

Re: Is 'cd -' to be considered (in ksh, bash) deprecated for scripting?

<87r0ynmfzn.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5790&group=comp.unix.shell#5790

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.unix.shell
Subject: Re: Is 'cd -' to be considered (in ksh, bash) deprecated for scripting?
Date: Mon, 31 Oct 2022 21:54:36 -0700
Organization: None to speak of
Lines: 45
Message-ID: <87r0ynmfzn.fsf@nosuchdomain.example.com>
References: <tjhrk0$37g49$1@dont-email.me> <20221028182456.668@kylheku.com>
<tjiu05$3e9u7$1@dont-email.me> <eli$2210291718@qaz.wtf>
<tjk805$3ndt9$1@dont-email.me> <20221031000940.53@kylheku.com>
<87v8o0m499.fsf@nosuchdomain.example.com>
<20221031092259.353@kylheku.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: reader01.eternal-september.org; posting-host="d0b5db7d2dd2e3bf3bccc1ff9c81cc3c";
logging-data="770652"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+qSWxQgHbMlVnAa34aYxa7"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:iPhTxWHt7YejnHuVF0f0qLvddmA=
sha1:PXuf04YVyX61/YHNn/LUCCriwuk=
 by: Keith Thompson - Tue, 1 Nov 2022 04:54 UTC

Kaz Kylheku <864-117-4973@kylheku.com> writes:
> On 2022-10-31, Keith Thompson <Keith.S.Thompson+u@gmail.com> wrote:
>> Kaz Kylheku <864-117-4973@kylheku.com> writes:
>>> If Vim had a way to exit unsuccessfully, [...]
>>> at least git and Bash will do the right thing.
>>
>> It does.
>>
>> ":cq" or ":cquit" exit with a status of 1.
>
> Wow, that is buried in the functionality.
>
> I've never heard of the use case hinted at by the documentation, with
> regard to the compilation scenario: that if you quit with a failed
> status, the compiler won't try to compile that file again.
>
> The idea must be that vim is in some kind of external loop
> invoked during a build to fix files with errors. To break out of that
> loop, you use :cq. Somethingg like:
>
> # while compilation fails, but editing doesn't, repeat:
>
> while ! $(CC) $< -o $@ && vim $@ ; do : ; done
>
> Except with a bit more complexity to invoke vim on the error
> output captured from the compiler as a quickfix list. (which is why
> this cq is buried in the quickfix command suite).
>
> This seems worth looking into because it has certain obvious advantages
> over iterating on "make -k" and fixing batches of errors:
>
>> It takes an optional
>> argument to specify a non-zero status (including 0).
>>
>> ":help cq" to see the documentation.
>
> The argument must be in newer Vim versions; none is documented for Vim
> 8.0, and it rejects arguments or prefixes.

The numeric argument was added in version 8.2.0095, 2020-01-06.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
[Watch this space]
void Void(void) { Void(); } /* The recursive call of the void */

Command line editing mode (was: Is 'cd -' to be considered (in ksh, bash) deprecated for scripting?)

<87h6zeed5g.fsf_-_@axel-reichert.de>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5791&group=comp.unix.shell#5791

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: mai...@axel-reichert.de (Axel Reichert)
Newsgroups: comp.unix.shell
Subject: Command line editing mode (was: Is 'cd -' to be considered (in ksh, bash) deprecated for scripting?)
Date: Fri, 04 Nov 2022 20:24:27 +0100
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <87h6zeed5g.fsf_-_@axel-reichert.de>
References: <tjhrk0$37g49$1@dont-email.me> <20221028182456.668@kylheku.com>
<tjiu05$3e9u7$1@dont-email.me> <eli$2210291718@qaz.wtf>
<tjk805$3ndt9$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: reader01.eternal-september.org; posting-host="d9179ebdfe014c79544808d9511fe963";
logging-data="2076316"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19RSep7eDLU/KCjCL+ouc0VK8MJnsWmntw="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:/AaVRVqY5YpLDygj63rO3RCCuIs=
sha1:g4Kjf0MhiDU903qJkDmwcGWzT5w=
 by: Axel Reichert - Fri, 4 Nov 2022 19:24 UTC

Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:

> Whenever a command gets typed that is getting lengthy (or use an
> inherently long compound command) I just "Esc v" and get a vi instance
> where I can continue typing any command with arbitrary complexity.

This is in fact the first time I read of somebody using this. Do you use
vi mode for other command line editing stuff as well? If so, can you
comment on the motivation? While I am an adherent to the other editor
religion, I can reasonably work with vi as well, but for command line
editing a mode-based paradigm seems especially strange. No holy wars, I
am genuinely curious. And even the vi users I know will normally stick
to bash's default emacs editing mode.

Best regards

Axel

Re: Command line editing mode (was: Is 'cd -' to be considered (in ksh, bash) deprecated for scripting?)

<tk3u82$3kirj$1@news.xmission.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5792&group=comp.unix.shell#5792

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gaze...@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: Re: Command line editing mode (was: Is 'cd -' to be considered (in ksh, bash) deprecated for scripting?)
Date: Fri, 4 Nov 2022 20:55:30 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <tk3u82$3kirj$1@news.xmission.com>
References: <tjhrk0$37g49$1@dont-email.me> <eli$2210291718@qaz.wtf> <tjk805$3ndt9$1@dont-email.me> <87h6zeed5g.fsf_-_@axel-reichert.de>
Injection-Date: Fri, 4 Nov 2022 20:55:30 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="3820403"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Fri, 4 Nov 2022 20:55 UTC

In article <87h6zeed5g.fsf_-_@axel-reichert.de>,
Axel Reichert <mail@axel-reichert.de> wrote:
>Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
>
>> Whenever a command gets typed that is getting lengthy (or use an
>> inherently long compound command) I just "Esc v" and get a vi instance
>> where I can continue typing any command with arbitrary complexity.
>
>This is in fact the first time I read of somebody using this. Do you use
>vi mode for other command line editing stuff as well? If so, can you
>comment on the motivation? While I am an adherent to the other editor
>religion, I can reasonably work with vi as well, but for command line
>editing a mode-based paradigm seems especially strange. No holy wars, I
>am genuinely curious. And even the vi users I know will normally stick
>to bash's default emacs editing mode.

Not me.

(And, yes, there really is nothing else to say - that won't lead us down
the path to a Holy War...)

--
The randomly chosen signature file that would have appeared here is more than 4
lines long. As such, it violates one or more Usenet RFCs. In order to remain
in compliance with said RFCs, the actual sig can be found at the following URL:
http://user.xmission.com/~gazelle/Sigs/EternalFlame

Re: Command line editing mode

<87y1sql5s4.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5793&group=comp.unix.shell#5793

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.unix.shell
Subject: Re: Command line editing mode
Date: Fri, 04 Nov 2022 15:21:47 -0700
Organization: None to speak of
Lines: 31
Message-ID: <87y1sql5s4.fsf@nosuchdomain.example.com>
References: <tjhrk0$37g49$1@dont-email.me> <20221028182456.668@kylheku.com>
<tjiu05$3e9u7$1@dont-email.me> <eli$2210291718@qaz.wtf>
<tjk805$3ndt9$1@dont-email.me> <87h6zeed5g.fsf_-_@axel-reichert.de>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: reader01.eternal-september.org; posting-host="d74099c2b109b60a9d4b4d88adbab987";
logging-data="2148850"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/phsAZs2GMZ20FGf8I3RrH"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:6EKeI0Zxh/gmpmR+mOfGoNicCAY=
sha1:vXZ/WhJf27vo3T8ZmU+XIrMEOIk=
 by: Keith Thompson - Fri, 4 Nov 2022 22:21 UTC

Axel Reichert <mail@axel-reichert.de> writes:
> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
>
>> Whenever a command gets typed that is getting lengthy (or use an
>> inherently long compound command) I just "Esc v" and get a vi instance
>> where I can continue typing any command with arbitrary complexity.
>
> This is in fact the first time I read of somebody using this. Do you use
> vi mode for other command line editing stuff as well? If so, can you
> comment on the motivation? While I am an adherent to the other editor
> religion, I can reasonably work with vi as well, but for command line
> editing a mode-based paradigm seems especially strange. No holy wars, I
> am genuinely curious. And even the vi users I know will normally stick
> to bash's default emacs editing mode.

I use C-x C-e, which is bound by default to edit-and-execute-command.
According to the bash documentation, it attempts to invoke $VISUAL,
$EDITOR, and emacs, in that order.

The new vi-edit-and-execute-command (which is not bound by default)
probably does the same thing but falls back to vi rather than emacs
(I haven't verified this). It was added in bash 5.2, but is not
mentioned in the bash documentation.

I use vim as my primary editor ($VISUAL and $EDITOR are both "vim"), but
I use the default emacs-style key bindings in bash.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for XCOM Labs
void Void(void) { Void(); } /* The recursive call of the void */

Re: Command line editing mode (was: Is 'cd -' to be considered (in ksh, bash) deprecated for scripting?)

<20221104160053.964@kylheku.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5794&group=comp.unix.shell#5794

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: 864-117-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.unix.shell
Subject: Re: Command line editing mode (was: Is 'cd -' to be considered (in
ksh, bash) deprecated for scripting?)
Date: Fri, 4 Nov 2022 23:06:33 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 36
Message-ID: <20221104160053.964@kylheku.com>
References: <tjhrk0$37g49$1@dont-email.me> <20221028182456.668@kylheku.com>
<tjiu05$3e9u7$1@dont-email.me> <eli$2210291718@qaz.wtf>
<tjk805$3ndt9$1@dont-email.me> <87h6zeed5g.fsf_-_@axel-reichert.de>
Injection-Date: Fri, 4 Nov 2022 23:06:33 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="6af4e4cbe0faef1caa7a0cdf157ffe3e";
logging-data="2177784"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19LSCs8VfgZYPh510SeZS61Dr1tba8GhS4="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:X4Xoq1hCAh3s+FLRCUds3CljxgU=
 by: Kaz Kylheku - Fri, 4 Nov 2022 23:06 UTC

On 2022-11-04, Axel Reichert <mail@axel-reichert.de> wrote:
> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
>
>> Whenever a command gets typed that is getting lengthy (or use an
>> inherently long compound command) I just "Esc v" and get a vi instance
>> where I can continue typing any command with arbitrary complexity.
>
> This is in fact the first time I read of somebody using this. Do you use
> vi mode for other command line editing stuff as well?

This is not a vi mode; it's just launching an external editor.

In Bash, Ctrl-X Ctrl-E does this, by default.

There are times when command-line editing is not up to snuff,
particularly when you have a multi-line command.

I implemented Ctrl-X Ctrl-E in the TXR Lisp REPL, which is based on a
substantially modified Linenoise library.

it's a must-have feature.

> If so, can you
> comment on the motivation? While I am an adherent to the other editor
> religion, I can reasonably work with vi as well, but for command line
> editing a mode-based paradigm seems especially strange. No holy wars, I
> am genuinely curious. And even the vi users I know will normally stick
> to bash's default emacs editing mode.

I set up vi editing mode in the shell profile of one particular service
account years ago. It keeps tripping me up every time I log into it, but
not enough for me to change it back. :)

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal

Re: Command line editing mode (was: Is 'cd -' to be considered (in ksh, bash) deprecated for scripting?)

<eli$2211042214@qaz.wtf>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5795&group=comp.unix.shell#5795

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!.POSTED.panix5.panix.com!qz!not-for-mail
From: *...@eli.users.panix.com (Eli the Bearded)
Newsgroups: comp.unix.shell
Subject: Re: Command line editing mode (was: Is 'cd -' to be considered (in ksh, bash) deprecated for scripting?)
Date: Sat, 5 Nov 2022 02:36:13 -0000 (UTC)
Organization: Some absurd concept
Message-ID: <eli$2211042214@qaz.wtf>
References: <tjhrk0$37g49$1@dont-email.me> <eli$2210291718@qaz.wtf> <tjk805$3ndt9$1@dont-email.me> <87h6zeed5g.fsf_-_@axel-reichert.de>
Injection-Date: Sat, 5 Nov 2022 02:36:13 -0000 (UTC)
Injection-Info: reader2.panix.com; posting-host="panix5.panix.com:166.84.1.5";
logging-data="10558"; mail-complaints-to="abuse@panix.com"
User-Agent: Vectrex rn 2.1 (beta)
X-Liz: It's actually happened, the entire Internet is a massive game of Redcode
X-Motto: "Erosion of rights never seems to reverse itself." -- kenny@panix
X-US-Congress: Moronic Fucks.
X-Attribution: EtB
XFrom: is a real address
Encrypted: double rot-13
 by: Eli the Bearded - Sat, 5 Nov 2022 02:36 UTC

In comp.unix.shell, Axel Reichert <mail@axel-reichert.de> wrote:
> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
>> Whenever a command gets typed that is getting lengthy (or use an
>> inherently long compound command) I just "Esc v" and get a vi instance
>> where I can continue typing any command with arbitrary complexity.
> This is in fact the first time I read of somebody using this.

I do this regularly. But I also regularly run long pipelines
and nested loops interactively.

> Do you use vi mode for other command line editing stuff as well?

100% yes. For one thing I have vi editing very well memorized, and
even ingrained. <esc>h or <esc>k are things I find myself doing in
very inappropriate places like web text boxes.

> If so, can you comment on the motivation? While I am an adherent
> to the other editor religion, I can reasonably work with vi as well,
> but for command line > editing a mode-based paradigm seems
> especially strange.

Once you think in vi, which I fully get that some people neither can nor
want to, it's not strange at all. Strange is not being able to use vi
mode edits on the : line within vi[*]. I use vi mode on my phone (with
"Hacker's Keyboard" and Termux shell.)

> And even the vi users I know will normally stick to bash's default
> emacs editing mode.

Other than arrow keys, I don't know how to use that effectively. I do a
lot of ssh into servers I've never touched before or su into shared
accounts and find myself confronted with the defaults of bash more often
than I'd like. Only one or two cW or rx type things make me reach for
"set -o vi".

[*] Solution ':map * "yyy@y' and then compose commands in the buffer,
hit <esc>* to execute them, then dd or undo the thing and edit it
again. This is how I compose large :g commands or complicated
substitutions.

Elijah
------
mz:'a,'e g/^>/ s/> *>/>>/g |normal 'z

Re: Command line editing mode

<tk4i8j$25bfa$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=5796&group=comp.unix.shell#5796

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Command line editing mode
Date: Sat, 5 Nov 2022 03:37:07 +0100
Organization: A noiseless patient Spider
Lines: 62
Message-ID: <tk4i8j$25bfa$1@dont-email.me>
References: <tjhrk0$37g49$1@dont-email.me> <20221028182456.668@kylheku.com>
<tjiu05$3e9u7$1@dont-email.me> <eli$2210291718@qaz.wtf>
<tjk805$3ndt9$1@dont-email.me> <87h6zeed5g.fsf_-_@axel-reichert.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 5 Nov 2022 02:37:07 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="c65e6d8ea4299be6ceec93aadd3a87b3";
logging-data="2272746"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/a+mCvR22DfMyVk/WKqqq5"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
Cancel-Lock: sha1:jr1veoqYwjT87nwvH+E8Ota0ZwI=
In-Reply-To: <87h6zeed5g.fsf_-_@axel-reichert.de>
X-Enigmail-Draft-Status: N1110
 by: Janis Papanagnou - Sat, 5 Nov 2022 02:37 UTC

On 04.11.2022 20:24, Axel Reichert wrote:
> Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
>
>> Whenever a command gets typed that is getting lengthy (or use an
>> inherently long compound command) I just "Esc v" and get a vi instance
>> where I can continue typing any command with arbitrary complexity.
>
> This is in fact the first time I read of somebody using this. Do you use
> vi mode for other command line editing stuff as well?

I'm not sure whether you are asking whether and why I prefer vim to
emacs or why I use the vi-mode of ksh compared to, say, tcsh's edit
features.

What I do is using vim (or vi) wherever some text has to be edited,
since I consider that tool the most flexible and most effective way.
(Only so much for the moment to keep this reply short.)

So, yes, I use it to edit a command line in a ksh session, and to
edit larger shell commands - the shell is a programming language as
other programming languages are, and I do edit programming languages
with vim.

> If so, can you comment on the motivation?

Of course I can do that. - I already started to write up something,
but hesitated to continue, because I got unsure whether I understood
the intention of your question correctly...

> While I am an adherent to the other editor
> religion, I can reasonably work with vi as well, but for command line
> editing a mode-based paradigm seems especially strange.

....so it's probably better if you elaborate on why and what you think
is "especially strange" so that I can better focus on the information
you're asking for.

> No holy wars, I am genuinely curious. And even the vi users I know
> will normally stick to bash's default emacs editing mode.

(The rest is off-topic and better disputed in comp.editors.)

The good thing is that we can choose whatever we want to use, so there's
also absolutely no need for holy wars. And I certainly don't want to
convince anyone. :-)
For the moment just an anecdote; I experienced (and heard similar
reports from other vi-users) that folks observing some vi-user are often
astonished that a) only few keystrokes can transform the whole file
(and I am *not* speaking about hidden complex macros in the background),
and b) that very complex tasks can be invoked that I haven't seen in any
other editor possible.

(I'll elaborate the vi-topic further on request.)

Janis

>
> Best regards
>
> Axel
>

Pages:123
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor