Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"I'm not afraid of dying, I just don't want to be there when it happens." -- Woody Allen


devel / comp.unix.shell / Simple (?) Script Question

SubjectAuthor
* Simple (?) Script QuestionGlenn P.,
+- Re: Simple (?) Script QuestionJanis Papanagnou
+* Re: Simple (?) Script QuestionChristian Weisgerber
|`- Re: Simple (?) Script QuestionJohn McCue
+* Re: Simple (?) Script QuestionKenny McCormack
|`* Re: Simple (?) Script QuestionGlenn P.,
| `- Re: Simple (?) Script QuestionKenny McCormack
+- Re: Simple (?) Script QuestionKeith Thompson
+* Re: Simple (?) Script QuestionAragorn
|`* Re: Simple (?) Script QuestionKenny McCormack
| `* Re: Simple (?) Script QuestionAragorn
|  `* Re: Simple (?) Script QuestionKenny McCormack
|   +- Re: Simple (?) Script QuestionGlenn P.,
|   +* Re: Simple (?) Script QuestionAragorn
|   |`* Re: Simple (?) Script QuestionKenny McCormack
|   | +* Re: Simple (?) Script QuestionWilliam Unruh
|   | |`- Re: Simple (?) Script QuestionSpiros Bousbouras
|   | `* Re: Simple (?) Script Questionjoerg
|   |  +- Re: Simple (?) Script QuestionKenny McCormack
|   |  `* Re: Simple (?) Script QuestionKaz Kylheku
|   |   `- Re: Simple (?) Script QuestionKaz Kylheku
|   +* Re: Simple (?) Script QuestionWilliam Unruh
|   |`- Re: Simple (?) Script QuestionKenny McCormack
|   `- Re: Simple (?) Script QuestionJohn McCue
`* Re: Simple (?) Script QuestionEd Morton
 `* Re: Simple (?) Script QuestionSpiros Bousbouras
  `- Re: Simple (?) Script QuestionEd Morton

Pages:12
Simple (?) Script Question

<alpine.DEB.2.11.2106031544340.8335@bfjrtb.sbkinyyrl.arg>

  copy mid

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

  copy link   Newsgroups: comp.unix.shell
Followup: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx08.iad.POSTED!not-for-mail
Newsgroups: comp.unix.shell
From: C128User...@FVI.Net (Glenn P.,)
Sender: c128user@oswego.foxvalley.net
Reply-To: "Glenn P.," <C128UserDELETE-THIS@FVI.Net>
Subject: Simple (?) Script Question
Message-ID: <alpine.DEB.2.11.2106031544340.8335@bfjrtb.sbkinyyrl.arg>
User-Agent: Alpine 2.11 (DEB 23 2013-08-11)
Return-Path: "Glenn P.," <C128UserDELETE-THIS@FVI.Net>
Followup-To: comp.unix.shell
Distribution: world
X-Gibberish: The Elephant says, "Tusk, tusk!".
X-Computer: "Commodore 64 BASIC v2 : 64K RAM System : 38911 BASIC Bytes Free"
Expires: 31 Dec 2021 23:59:59 -0400
Content-Transfer-Encoding: 7Bit
Conversion: Prohibited
Content-Language: en-US
X-Mailer: Unix Alpine v2.11
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Lines: 31
X-Complaints-To: abuse@foxvalley.net
NNTP-Posting-Date: Thu, 03 Jun 2021 20:08:09 UTC
Date: Thu, 3 Jun 2021 16:08:06 -0400
X-Received-Bytes: 2105
 by: Glenn P., - Thu, 3 Jun 2021 20:08 UTC

I'm on a Unix shell account using TCSH and when changing
directories have been first issuing a "cd" comnand, followed
by an "ls" comnand.

I'd like to write a script that combines these two so that I
only need to enter ONE command and not two.

This is what I've tried:

!/bin/tcsh
cd $*
clear
/bin/ls -AFog | more

This results in a comnand that displays the specified target
directory OK, but an "ls" or "pwd" shows that the working
directory has NOT been changed!

This is starting to bug me a little: surely this SHOULD be
a simple script to write!

What am I doing wrong? Can somebody help? Many thanks for
any assistance...

-- %%%%%%%%% "Glenn P.," <C128UserDELETE-THIS@FVI.Net> %%%%%%%%%%%%
===================================================================
"All of the scenes in this program, whether actual or created,
depict authenticated facts." ------------------------------------
--"Mutual of Omaha's 'Wild Kingdom'"

:: Take Note Of The Spam Block On My E-Mail Address! ::

Re: Simple (?) Script Question

<s9bg93$60t$1@news-1.m-online.net>

  copy mid

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

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.szaf.org!news.karotte.org!news.space.net!news.m-online.net!.POSTED!not-for-mail
From: janis_pa...@hotmail.com (Janis Papanagnou)
Newsgroups: comp.unix.shell
Subject: Re: Simple (?) Script Question
Date: Thu, 3 Jun 2021 23:06:43 +0200
Organization: (posted via) M-net Telekommunikations GmbH
Lines: 46
Message-ID: <s9bg93$60t$1@news-1.m-online.net>
References: <alpine.DEB.2.11.2106031544340.8335@bfjrtb.sbkinyyrl.arg>
NNTP-Posting-Host: 2001:a61:252a:da01:4056:b28d:7587:2c10
Mime-Version: 1.0
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
X-Trace: news-1.m-online.net 1622754403 6173 2001:a61:252a:da01:4056:b28d:7587:2c10 (3 Jun 2021 21:06:43 GMT)
X-Complaints-To: news@news-1.m-online.net
NNTP-Posting-Date: Thu, 3 Jun 2021 21:06:43 +0000 (UTC)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101
Thunderbird/45.8.0
X-Enigmail-Draft-Status: N1110
In-Reply-To: <alpine.DEB.2.11.2106031544340.8335@bfjrtb.sbkinyyrl.arg>
 by: Janis Papanagnou - Thu, 3 Jun 2021 21:06 UTC

On 03.06.2021 22:08, Glenn P., wrote:
> I'm on a Unix shell account using TCSH and when changing
> directories have been first issuing a "cd" comnand, followed
> by an "ls" comnand.
>
> I'd like to write a script that combines these two so that I
> only need to enter ONE command and not two.
>
> This is what I've tried:
>
> !/bin/tcsh
> cd $*
> clear
> /bin/ls -AFog | more
>
> This results in a comnand that displays the specified target
> directory OK, but an "ls" or "pwd" shows that the working
> directory has NOT been changed!
>
> This is starting to bug me a little: surely this SHOULD be
> a simple script to write!
>
> What am I doing wrong? Can somebody help? Many thanks for
> any assistance...

Where to start...?! - I don't want to open a can of worms. - Let's
try this way...

In any standard shell (not tcsh), ksh in my case, I define in the
shell's .kshrc file

alias cd=_cd
function _cd
{
\cd "$@"
...
}

with "..." replaced by your custom code.

You could of course - and that's probably better - use a new name
for your compound command, say call the function 'cdl' or 'cdls'
(and omit the cd-alias and the \-escape above).

Janis

Re: Simple (?) Script Question

<slrnsbilp4.23hf.naddy@lorvorc.mips.inka.de>

  copy mid

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

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.szaf.org!inka.de!mips.inka.de!.POSTED.localhost!not-for-mail
From: nad...@mips.inka.de (Christian Weisgerber)
Newsgroups: comp.unix.shell
Subject: Re: Simple (?) Script Question
Date: Thu, 3 Jun 2021 22:26:44 -0000 (UTC)
Message-ID: <slrnsbilp4.23hf.naddy@lorvorc.mips.inka.de>
References: <alpine.DEB.2.11.2106031544340.8335@bfjrtb.sbkinyyrl.arg>
Injection-Date: Thu, 3 Jun 2021 22:26:44 -0000 (UTC)
Injection-Info: lorvorc.mips.inka.de; posting-host="localhost:::1";
logging-data="69168"; mail-complaints-to="usenet@mips.inka.de"
User-Agent: slrn/1.0.3 (FreeBSD)
 by: Christian Weisgerber - Thu, 3 Jun 2021 22:26 UTC

On 2021-06-03, Glenn P., <C128UserDELETE-THIS@FVI.Net> wrote:

> !/bin/tcsh
> cd $*
> clear
> /bin/ls -AFog | more
>
> This results in a comnand that displays the specified target
> directory OK, but an "ls" or "pwd" shows that the working
> directory has NOT been changed!

The working directory is a property of the process. When you run
your script, it is executed in a child process. The change in
working directory does not propagate back to the parent process,
i.e., your interactive instance of tcsh.

The way to solve this is to use a shell alias, which is executed
within the current shell process:

% alias cdls 'cd \!:1 ; clear ; /bin/ls -AFog | more'

--
Christian "naddy" Weisgerber naddy@mips.inka.de

Re: Simple (?) Script Question

<s9bmap$1niau$1@news.xmission.com>

  copy mid

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

  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: Simple (?) Script Question
Date: Thu, 3 Jun 2021 22:50:01 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <s9bmap$1niau$1@news.xmission.com>
References: <alpine.DEB.2.11.2106031544340.8335@bfjrtb.sbkinyyrl.arg>
Injection-Date: Thu, 3 Jun 2021 22:50:01 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="1821022"; 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 - Thu, 3 Jun 2021 22:50 UTC

In article <alpine.DEB.2.11.2106031544340.8335@bfjrtb.sbkinyyrl.arg>,
Glenn P., <C128UserDELETE-THIS@FVI.Net> wrote:
>I'm on a Unix shell account using TCSH and when changing
>directories have been first issuing a "cd" comnand, followed
>by an "ls" comnand.

alias cwdcmd ls

--
I love the poorly educated.

Re: Simple (?) Script Question

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

  copy mid

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

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.unix.shell
Subject: Re: Simple (?) Script Question
Date: Thu, 03 Jun 2021 17:09:10 -0700
Organization: None to speak of
Lines: 51
Message-ID: <87lf7qwkwp.fsf@nosuchdomain.example.com>
References: <alpine.DEB.2.11.2106031544340.8335@bfjrtb.sbkinyyrl.arg>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="79a2d783cb3312756c8301564188b04a";
logging-data="26008"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+v/XDclArJaxhPVDR15rqV"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux)
Cancel-Lock: sha1:vmKU2tGTNId1n5ZiS7JKT52p+Mg=
sha1:lahmWSg3YQ02ZpARF8r5/k3a2Lk=
 by: Keith Thompson - Fri, 4 Jun 2021 00:09 UTC

"Glenn P.," <C128UserDELETE-THIS@FVI.Net> writes:
> I'm on a Unix shell account using TCSH and when changing
> directories have been first issuing a "cd" comnand, followed
> by an "ls" comnand.
>
> I'd like to write a script that combines these two so that I
> only need to enter ONE command and not two.
>
> This is what I've tried:
>
> !/bin/tcsh
> cd $*
> clear
> /bin/ls -AFog | more

That first line needs to be "#!", not "!" (I'm guessing that's a
copy-and-paste error).

I personally wouldn't want to clear the screen, but of course that's up
to you.

> This results in a comnand that displays the specified target
> directory OK, but an "ls" or "pwd" shows that the working
> directory has NOT been changed!

Right. It's changed in the process running the script, not in your
current interactive shell process that invoked the script.

If you want a "cd" command to affect the current shell process, it needs
to be in an alias (or in a shell function if you're using a shell that
supports functions). Back when I still used tcsh, I had these aliases
in my .cshrc :

alias l ls -AF
alias cdl 'cd \!$ ; l'

In bash, I have these functions:

l() { ls -AF "$@" ; }
cdl () { cd "$@" && l ; }

Tweak to taste.

(An aside: Abandoning tcsh and switching to bash was one of the better
decisions I've made -- which doesn't necessarily imply that you should
do it.)

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

Re: Simple (?) Script Question

<20210604114734.1675996c@nx-74205>

  copy mid

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

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: thoron...@telenet.be (Aragorn)
Newsgroups: comp.unix.shell
Subject: Re: Simple (?) Script Question
Date: Fri, 4 Jun 2021 11:47:34 +0200
Organization: A noiseless patient Strider
Lines: 58
Message-ID: <20210604114734.1675996c@nx-74205>
References: <alpine.DEB.2.11.2106031544340.8335@bfjrtb.sbkinyyrl.arg>
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: reader02.eternal-september.org; posting-host="4d9fb5580620388507b35f4a82edbe7d";
logging-data="1048"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX187jQOqNbXcV54pgzoamTWS"
Cancel-Lock: sha1:Y2m/Q7nTLlRw9o+bJkyVyyYm42k=
X-Newsreader: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu)
 by: Aragorn - Fri, 4 Jun 2021 09:47 UTC

On 03.06.2021 at 16:08, Glenn P., scribbled:

> I'm on a Unix shell account using TCSH and when changing
> directories have been first issuing a "cd" comnand, followed
> by an "ls" comnand.
>
> I'd like to write a script that combines these two so that I
> only need to enter ONE command and not two.
>
> This is what I've tried:
>
> !/bin/tcsh
> cd $*
> clear
> /bin/ls -AFog | more
>
> This results in a comnand that displays the specified target
> directory OK, but an "ls" or "pwd" shows that the working
> directory has NOT been changed!

Normally, "cd" is a shell builtin (in most shells), and considering
that you're invoking it from within a shell script, it is run in a
subshell of your login shell. Therefore, it is the subshell that
executes the "cd", and upon exiting the script, the subshell is
terminated and you return to its parent shell.

> This is starting to bug me a little: surely this SHOULD be
> a simple script to write!
>
> What am I doing wrong? Can somebody help? Many thanks for
> any assistance...

I have no experience with the C shell, but in GNU Bash and comparable
shells, you can write a shell function, which you can export via your
~/.bashrc, ~/.bash_profile or ~/.profile. Something like...

my_function ()
{
cd "$1"
clear
ls -AFog | more
}
export -f my_function

You can then invoke the function name at the prompt as a regular
command.

P.S.: The C shell is preferred by many as an interactive shell, but it
is generally recommended against as a scripting shell, because
its behavior for advanced scripting is very often unspecified and
inconsistent.

--
With respect,
= Aragorn =

Re: Simple (?) Script Question

<s9ct3j$1o7gm$1@news.xmission.com>

  copy mid

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

  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: Simple (?) Script Question
Date: Fri, 4 Jun 2021 09:51:47 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <s9ct3j$1o7gm$1@news.xmission.com>
References: <alpine.DEB.2.11.2106031544340.8335@bfjrtb.sbkinyyrl.arg> <20210604114734.1675996c@nx-74205>
Injection-Date: Fri, 4 Jun 2021 09:51:47 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="1842710"; 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 Jun 2021 09:51 UTC

In article <20210604114734.1675996c@nx-74205>,
Aragorn <thorongil@telenet.be> wrote:
....
>I have no experience with the C shell, but in GNU Bash and comparable

Well, then, and meaning no disrespect, maybe you don't have much to add to
a Usenet thread that is explicitly about exactly one particular shell: tcsh.

Anyway, I gave the proper and correct answer yesterday. You don't need to
re-define "cd" at all. Just define "cwdcmd".

--
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/InsaneParty

Re: Simple (?) Script Question

<20210604124104.28f8045e@nx-74205>

  copy mid

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

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: thoron...@telenet.be (Aragorn)
Newsgroups: comp.unix.shell
Subject: Re: Simple (?) Script Question
Date: Fri, 4 Jun 2021 12:41:04 +0200
Organization: A noiseless patient Strider
Lines: 28
Message-ID: <20210604124104.28f8045e@nx-74205>
References: <alpine.DEB.2.11.2106031544340.8335@bfjrtb.sbkinyyrl.arg>
<20210604114734.1675996c@nx-74205>
<s9ct3j$1o7gm$1@news.xmission.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: reader02.eternal-september.org; posting-host="4d9fb5580620388507b35f4a82edbe7d";
logging-data="1048"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18T9Hd87E+6wjE20a85seW/"
Cancel-Lock: sha1:d36upNt4e4DEiLJbvgbT+//6VYw=
X-Newsreader: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu)
 by: Aragorn - Fri, 4 Jun 2021 10:41 UTC

On 04.06.2021 at 09:51, Kenny McCormack scribbled:

> In article <20210604114734.1675996c@nx-74205>,
> Aragorn <thorongil@telenet.be> wrote:
>
> > I have no experience with the C shell, but in GNU Bash and
> > comparable
>
> Well, then, and meaning no disrespect, maybe you don't have much to
> add to a Usenet thread that is explicitly about exactly one
> particular shell: tcsh.

True. I didn't mean to be stepping on anybody's toes.

> Anyway, I gave the proper and correct answer yesterday. You don't
> need to re-define "cd" at all. Just define "cwdcmd".

Yes, but you proposed doing it via an alias and...

1. I don't know whether the C shell supports compound aliases; and

2. I generally recommend using shell functions instead of aliases.

--
With respect,
= Aragorn =

Re: Simple (?) Script Question

<s9d02d$rqf$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: mortons...@gmail.com (Ed Morton)
Newsgroups: comp.unix.shell
Subject: Re: Simple (?) Script Question
Date: Fri, 4 Jun 2021 05:42:22 -0500
Organization: A noiseless patient Spider
Lines: 22
Message-ID: <s9d02d$rqf$1@dont-email.me>
References: <alpine.DEB.2.11.2106031544340.8335@bfjrtb.sbkinyyrl.arg>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Fri, 4 Jun 2021 10:42:21 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="167d19babc1f51d3104b806457914bb0";
logging-data="28495"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+U/KJNp87XUAJcqV0Owpxt"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.10.2
Cancel-Lock: sha1:4xDfxO7eiQqv8VW9px75ai1Ayqk=
In-Reply-To: <alpine.DEB.2.11.2106031544340.8335@bfjrtb.sbkinyyrl.arg>
X-Antivirus-Status: Clean
Content-Language: en-US
X-Antivirus: Avast (VPS 210604-0, 06/03/2021), Outbound message
 by: Ed Morton - Fri, 4 Jun 2021 10:42 UTC

On 6/3/2021 3:08 PM, Glenn P., wrote:
> I'm on a Unix shell account using TCSH and when changing
> directories have been first issuing a "cd" comnand, followed
> by an "ls" comnand.
>
> I'd like to write a script that combines these two so that I
> only need to enter ONE command and not two.
>
> This is what I've tried:
>
> !/bin/tcsh
> cd $*
> clear
> /bin/ls -AFog | more

Don't write scripts using [t]csh. See
https://www.grymoire.com/Unix/CshTop10.txt or just google it:
https://www.google.com/search?q=csh+why+not

Regards,

Ed.

Re: Simple (?) Script Question

<s9d29d$1ob40$1@news.xmission.com>

  copy mid

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

  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: Simple (?) Script Question
Date: Fri, 4 Jun 2021 11:20:13 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <s9d29d$1ob40$1@news.xmission.com>
References: <alpine.DEB.2.11.2106031544340.8335@bfjrtb.sbkinyyrl.arg> <20210604114734.1675996c@nx-74205> <s9ct3j$1o7gm$1@news.xmission.com> <20210604124104.28f8045e@nx-74205>
Injection-Date: Fri, 4 Jun 2021 11:20:13 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="1846400"; 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 Jun 2021 11:20 UTC

In article <20210604124104.28f8045e@nx-74205>,
Aragorn <thorongil@telenet.be> wrote:
....
>> Anyway, I gave the proper and correct answer yesterday. You don't
>> need to re-define "cd" at all. Just define "cwdcmd".
>
>Yes, but you proposed doing it via an alias and...

Not really. I think you need to do "man tcsh" and search for "cwdcmd".

> 1. I don't know whether the C shell supports compound aliases; and

??? What is a "compound alias" ???

> 2. I generally recommend using shell functions instead of aliases.

tcsh doesn't have shell functions. You might as well be recommending pink
unicorns. tcsh doesn't have those either.

--
In Usenet, as in life, as you go through it, you will run into lots of nonsense.
Each time, you will have to decide from the following courses of action:
1) Argue with it or 2) Ignore it.
Experience shows that the later course is usually the best.

Re: Simple (?) Script Question

<against-universals@bongo-ra.co>

  copy mid

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

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!aioe.org!news.uzoreto.com!news-out.netnews.com!news.alt.net!fdc2.netnews.com!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!fx03.ams4.POSTED!not-for-mail
From: spi...@gmail.com (Spiros Bousbouras)
Newsgroups: comp.unix.shell
Subject: Re: Simple (?) Script Question
Message-ID: <against-universals@bongo-ra.co>
References: <alpine.DEB.2.11.2106031544340.8335@bfjrtb.sbkinyyrl.arg> <s9d02d$rqf$1@dont-email.me>
In-Reply-To: <s9d02d$rqf$1@dont-email.me>
X-Organisation: Weyland-Yutani
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
Lines: 26
X-Complaints-To: http://netreport.virginmedia.com
NNTP-Posting-Date: Fri, 04 Jun 2021 12:13:38 UTC
Organization: virginmedia.com
Date: Fri, 04 Jun 2021 12:13:38 GMT
X-Received-Bytes: 1680
 by: Spiros Bousbouras - Fri, 4 Jun 2021 12:13 UTC

On Fri, 4 Jun 2021 05:42:22 -0500
Ed Morton <mortonspam@gmail.com> wrote:
> On 6/3/2021 3:08 PM, Glenn P., wrote:
> > I'm on a Unix shell account using TCSH and when changing
> > directories have been first issuing a "cd" comnand, followed
> > by an "ls" comnand.
> >
> > I'd like to write a script that combines these two so that I
> > only need to enter ONE command and not two.
> >
> > This is what I've tried:
> >
> > !/bin/tcsh
> > cd $*
> > clear
> > /bin/ls -AFog | more
>
> Don't write scripts using [t]csh. See
> https://www.grymoire.com/Unix/CshTop10.txt or just google it:
> https://www.google.com/search?q=csh+why+not

I have written dozens of scripts using tcsh and it works fine. That's not
to say that for some programming tasks another programming language might not
be better suited
for some appropriate definition of "better"
for some appropriate definition of "appropriate" !

Re: Simple (?) Script Question

<alpine.DEB.2.11.2106040934430.16847@bfjrtb.sbkinyyrl.arg>

  copy mid

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

  copy link   Newsgroups: comp.unix.shell
Followup: comp.unix.shell
Path: i2pn2.org!i2pn.org!paganini.bofh.team!news.dns-netz.com!news.freedyn.net!newsreader4.netcologne.de!news.netcologne.de!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx36.iad.POSTED!not-for-mail
Newsgroups: comp.unix.shell
From: C128User...@FVI.Net (Glenn P.,)
Sender: c128user@oswego.foxvalley.net
Reply-To: "Glenn P.," <C128UserDELETE-THIS@FVI.Net>
Subject: Re: Simple (?) Script Question
In-Reply-To: <s9d29d$1ob40$1@news.xmission.com>
Message-ID: <alpine.DEB.2.11.2106040934430.16847@bfjrtb.sbkinyyrl.arg>
References: <alpine.DEB.2.11.2106031544340.8335@bfjrtb.sbkinyyrl.arg> <20210604114734.1675996c@nx-74205> <s9ct3j$1o7gm$1@news.xmission.com> <20210604124104.28f8045e@nx-74205> <s9d29d$1ob40$1@news.xmission.com>
User-Agent: Alpine 2.11 (DEB 23 2013-08-11)
Return-Path: "Glenn P.," <C128UserDELETE-THIS@FVI.Net>
Followup-To: comp.unix.shell
Distribution: world
X-Gibberish: The Elephant says, "Tusk, tusk!".
X-Computer: "Commodore 64 BASIC v2 : 64K RAM System : 38911 BASIC Bytes Free"
Expires: 31 Dec 2021 23:59:59 -0400
Content-Transfer-Encoding: 7Bit
Conversion: Prohibited
Content-Language: en-US
X-Mailer: Unix Alpine v2.11
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Lines: 15
X-Complaints-To: abuse@foxvalley.net
NNTP-Posting-Date: Fri, 04 Jun 2021 13:38:22 UTC
Date: Fri, 4 Jun 2021 09:38:19 -0400
X-Received-Bytes: 2072
 by: Glenn P., - Fri, 4 Jun 2021 13:38 UTC

On 04-Jun-21 at 7:20am -0000, <gazelle@shell.xmission.com> wrote:

> tcsh doesn't have shell functions. You might as well be
> recommending pink unicorns. tcsh doesn't have those either.

Now, children... let's not fight. :o

--_____ %%%%%%%%%%%% "Glenn P.," <C128UserDELETE-THIS@FVI.Net> %%%%%%%%%%%%
{~._.~} -------------------------------------------------------------------
_( Y )_ "...And remember, my sentimental friend, that a heart is not
(:_~*~_:) judged by how much YOU love, but by how much YOU are loved by
(_)-(_) OTHERS." --------------------------------------
========= --Wizard of Oz to Tin Man (MGM Movie).

:: Take Note Of The Spam Block On My E-Mail Address! ::

Re: Simple (?) Script Question

<20210604154709.2d526bc9@nx-74205>

  copy mid

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

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: thoron...@telenet.be (Aragorn)
Newsgroups: comp.unix.shell
Subject: Re: Simple (?) Script Question
Date: Fri, 4 Jun 2021 15:47:09 +0200
Organization: A noiseless patient Strider
Lines: 31
Message-ID: <20210604154709.2d526bc9@nx-74205>
References: <alpine.DEB.2.11.2106031544340.8335@bfjrtb.sbkinyyrl.arg>
<20210604114734.1675996c@nx-74205>
<s9ct3j$1o7gm$1@news.xmission.com>
<20210604124104.28f8045e@nx-74205>
<s9d29d$1ob40$1@news.xmission.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Injection-Info: reader02.eternal-september.org; posting-host="4d9fb5580620388507b35f4a82edbe7d";
logging-data="1048"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/67BuSSHMEMFhjK3m+Jc9d"
Cancel-Lock: sha1:+jSKLZaYJKeQBd49+1+HuJbIKNI=
X-Newsreader: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu)
 by: Aragorn - Fri, 4 Jun 2021 13:47 UTC

On 04.06.2021 at 11:20, Kenny McCormack scribbled:

> In article <20210604124104.28f8045e@nx-74205>,
> Aragorn <thorongil@telenet.be> wrote:
> ...
> >> Anyway, I gave the proper and correct answer yesterday. You don't
> >> need to re-define "cd" at all. Just define "cwdcmd".
> >
> >Yes, but you proposed doing it via an alias and...
>
> Not really. I think you need to do "man tcsh" and search for
> "cwdcmd".

I now understand what you meant. Earlier I did not.

> > 1. I don't know whether the C shell supports compound aliases; and
> >
>
> ??? What is a "compound alias" ???

That statement came from my not understanding what you were advising.
I appeared to me as if you were recommending that the OP create an
alias, composed of multiple commands — which is not supported in GNU
Bash or any Bourne-style shell I'm aware of.

I understand now that I was misreading you. My apologies.

--
With respect,
= Aragorn

Re: Simple (?) Script Question

<s9dcpc$onk$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: unr...@invalid.ca (William Unruh)
Newsgroups: comp.unix.shell
Subject: Re: Simple (?) Script Question
Date: Fri, 4 Jun 2021 14:19:25 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 44
Message-ID: <s9dcpc$onk$1@dont-email.me>
References: <alpine.DEB.2.11.2106031544340.8335@bfjrtb.sbkinyyrl.arg>
<20210604114734.1675996c@nx-74205> <s9ct3j$1o7gm$1@news.xmission.com>
<20210604124104.28f8045e@nx-74205> <s9d29d$1ob40$1@news.xmission.com>
Injection-Date: Fri, 4 Jun 2021 14:19:25 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="5643801be21f76100bda01b2a1cabe7e";
logging-data="25332"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Ouju2OqMGXoL9o+oe3uRg"
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:DX18iwHZ5HWKz0fjqkAoybZLM4c=
 by: William Unruh - Fri, 4 Jun 2021 14:19 UTC

On 2021-06-04, Kenny McCormack <gazelle@shell.xmission.com> wrote:
> In article <20210604124104.28f8045e@nx-74205>,
> Aragorn <thorongil@telenet.be> wrote:
> ...
>>> Anyway, I gave the proper and correct answer yesterday. You don't
>>> need to re-define "cd" at all. Just define "cwdcmd".
>>
>>Yes, but you proposed doing it via an alias and...
>
> Not really. I think you need to do "man tcsh" and search for "cwdcmd".
>
>> 1. I don't know whether the C shell supports compound aliases; and
>
> ??? What is a "compound alias" ???

It is a command whixh is composed of many parts. An alias is a direct
substitution. Ie, if you see see an aliased command the shell simply
replaces it literally with the alias, letter for letter. It does not
allow arguments. Thus replacing

"newcmd <dir>" with "cd <dir>;ls " does not work as an alias. since
the <dir> cannot be stuffed into the middle of an alias. It can for a
function.

The above is in bash

tcsh apparently does not have functions (one of the reasons bash i
superiour) However, tcsh does allow a form. you can use th ! history
substitution in an alias apparently.

Thus
alias newcmd ='cd !^ ; ls'
should work with !^ meaning substitue the first word after the newcmd
into that position.
Do not rely on my description since I also do not use tcsh

>
>> 2. I generally recommend using shell functions instead of aliases.
>
> tcsh doesn't have shell functions. You might as well be recommending pink
> unicorns. tcsh doesn't have those either.
>

Re: Simple (?) Script Question

<s9ddpc$1omsk$1@news.xmission.com>

  copy mid

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

  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: Simple (?) Script Question
Date: Fri, 4 Jun 2021 14:36:28 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <s9ddpc$1omsk$1@news.xmission.com>
References: <alpine.DEB.2.11.2106031544340.8335@bfjrtb.sbkinyyrl.arg> <20210604124104.28f8045e@nx-74205> <s9d29d$1ob40$1@news.xmission.com> <20210604154709.2d526bc9@nx-74205>
Injection-Date: Fri, 4 Jun 2021 14:36:28 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="1858452"; 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 Jun 2021 14:36 UTC

In article <20210604154709.2d526bc9@nx-74205>,
Aragorn <thorongil@telenet.be> wrote:
....
>It appeared to me as if you were recommending that the OP create an
>alias, composed of multiple commands which is not supported in GNU
>Bash or any Bourne-style shell I'm aware of.

$ alias foo='echo hello;echo bye'
$ foo
hello
bye
$

Any shell that supports aliases supports multiple commands (as above).

What bash aliases do not support - and this is what severely limits their
usability - is embedded arguments in the alias. I.e., in the above alias,
you couldn't make the "hello" part a runtime argument.

But csh and tcsh do, in fact, support embedded arguments in aliases. So,
that's a good thing...

Of course, as noted many times so far, what bash or any shell other than
tcsh does, is irrelevant in this thread.

--
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/LadyChatterley

Re: Simple (?) Script Question

<s9dhv9$u8i$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: unr...@invalid.ca (William Unruh)
Newsgroups: comp.unix.shell
Subject: Re: Simple (?) Script Question
Date: Fri, 4 Jun 2021 15:47:53 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 35
Message-ID: <s9dhv9$u8i$1@dont-email.me>
References: <alpine.DEB.2.11.2106031544340.8335@bfjrtb.sbkinyyrl.arg>
<20210604124104.28f8045e@nx-74205> <s9d29d$1ob40$1@news.xmission.com>
<20210604154709.2d526bc9@nx-74205> <s9ddpc$1omsk$1@news.xmission.com>
Injection-Date: Fri, 4 Jun 2021 15:47:53 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="5643801be21f76100bda01b2a1cabe7e";
logging-data="30994"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+QN2zICuyWnJ1Z3QfYoGHN"
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:F2l8AVwE9Pw/oix/P7KvIBnMPnQ=
 by: William Unruh - Fri, 4 Jun 2021 15:47 UTC

On 2021-06-04, Kenny McCormack <gazelle@shell.xmission.com> wrote:
> In article <20210604154709.2d526bc9@nx-74205>,
> Aragorn <thorongil@telenet.be> wrote:
> ...
>>It appeared to me as if you were recommending that the OP create an
>>alias, composed of multiple commands which is not supported in GNU
>>Bash or any Bourne-style shell I'm aware of.
>
> $ alias foo='echo hello;echo bye'
> $ foo
> hello
> bye
> $
>
> Any shell that supports aliases supports multiple commands (as above).
>
> What bash aliases do not support - and this is what severely limits their
> usability - is embedded arguments in the alias. I.e., in the above alias,
> you couldn't make the "hello" part a runtime argument.

Which is why the bash shell has functions. Which DO support embedded
arguments.

>
> But csh and tcsh do, in fact, support embedded arguments in aliases. So,
> that's a good thing...
>
> Of course, as noted many times so far, what bash or any shell other than
> tcsh does, is irrelevant in this thread.

It depends. The user has a problem. He happens to have the problem
because he runs tcsh. Thus presenting a solution which uses something
else may very well be relevant.

Re: Simple (?) Script Question

<s9dl7q$1oq5u$1@news.xmission.com>

  copy mid

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

  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: Simple (?) Script Question
Date: Fri, 4 Jun 2021 16:43:38 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <s9dl7q$1oq5u$1@news.xmission.com>
References: <alpine.DEB.2.11.2106031544340.8335@bfjrtb.sbkinyyrl.arg> <20210604124104.28f8045e@nx-74205> <s9d29d$1ob40$1@news.xmission.com> <s9dcpc$onk$1@dont-email.me>
Injection-Date: Fri, 4 Jun 2021 16:43:38 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="1861822"; 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 Jun 2021 16:43 UTC

In article <s9dcpc$onk$1@dont-email.me>,
William Unruh <unruh@invalid.ca> wrote:
....
>It is a command which is composed of many parts (duh). An alias is a
>direct substitution. I.e., if you see see an aliased command the shell
>simply replaces it literally with the alias, letter for letter. It does
>not allow arguments.

Yes, it does. Don't argue with this; just go back and re-read my earlier
posts. tcsh aliases *DO* allow embedded arguments. End of Story.

And, obviously - can't believe I have to point this out yet *again*,
but I do - the implementation of aliases in any other shell is
completely irrelevant in this thread.

>Do not rely on anything I say about tcsh since I know absolutely nothing
>about it.

Interestingly, I know zip, zero, nada about zsh. Therefore, I abstain from
posting anything on zsh-related threads when they come up in the newsgroup.

I think there is a lesson in there somewhere.

--
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/Cancer

Re: Simple (?) Script Question

<not-me@bongo-ra.co>

  copy mid

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

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!paganini.bofh.team!news.dns-netz.com!news.freedyn.net!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!peer03.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!fx02.ams4.POSTED!not-for-mail
From: spi...@gmail.com (Spiros Bousbouras)
Newsgroups: comp.unix.shell
Subject: Re: Simple (?) Script Question
Message-ID: <not-me@bongo-ra.co>
References: <alpine.DEB.2.11.2106031544340.8335@bfjrtb.sbkinyyrl.arg> <20210604124104.28f8045e@nx-74205> <s9d29d$1ob40$1@news.xmission.com>
<20210604154709.2d526bc9@nx-74205> <s9ddpc$1omsk$1@news.xmission.com> <s9dhv9$u8i$1@dont-email.me>
In-Reply-To: <s9dhv9$u8i$1@dont-email.me>
X-Organisation: Weyland-Yutani
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
Lines: 35
X-Complaints-To: http://netreport.virginmedia.com
NNTP-Posting-Date: Fri, 04 Jun 2021 16:56:40 UTC
Organization: virginmedia.com
Date: Fri, 04 Jun 2021 16:56:40 GMT
X-Received-Bytes: 2586
 by: Spiros Bousbouras - Fri, 4 Jun 2021 16:56 UTC

On Fri, 4 Jun 2021 15:47:53 -0000 (UTC)
William Unruh <unruh@invalid.ca> wrote:
> On 2021-06-04, Kenny McCormack <gazelle@shell.xmission.com> wrote:
> > Of course, as noted many times so far, what bash or any shell other than
> > tcsh does, is irrelevant in this thread.
>
> It depends. The user has a problem. He happens to have the problem
> because he runs tcsh.

No. The functionality he wants to achieve is that he wants to have one
command which changes the working directory and prints a listing. This
functionality is independent of any shell. The functionality would be kind of
automatic if he was using a file manager instead of the command line because
clicking on a directory would change the "working directory" of the file
manager and print a listing of the new directory (at least this is how file
managers tend to work). So a suggestion that he use a file manager instead of
the command line would be less of a derail than the suggestion that he use a
different shell.

Furthermore , he wasn't getting what he wanted with his initial effort
because he didn't take into account that a working directory is per process.
Again this is independent from which shell he uses.

> Thus presenting a solution which uses something
> else may very well be relevant.

If one adopts a wide enough context then anything can become relevant. For
example , if the opening poster were to forego all use of computers and live
as a hermit in the woods , it would also solve his problem. So with this
context , survivalist advice would also be relevant.

--
A good compiler can translate an 8K BASIC program in two or three
minutes.
http://www.atariarchives.org/mlb/chapter7.php

Re: Simple (?) Script Question

<s9fqbr$du$1@news.dns-netz.com>

  copy mid

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

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!aioe.org!news.dns-netz.com!news.freedyn.net!.POSTED!not-for-mail
From: joe...@schily.net
Newsgroups: comp.unix.shell
Subject: Re: Simple (?) Script Question
Date: Sat, 5 Jun 2021 12:23:23 -0000 (UTC)
Message-ID: <s9fqbr$du$1@news.dns-netz.com>
References: <alpine.DEB.2.11.2106031544340.8335@bfjrtb.sbkinyyrl.arg> <s9d29d$1ob40$1@news.xmission.com> <20210604154709.2d526bc9@nx-74205> <s9ddpc$1omsk$1@news.xmission.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: eJxdjcEKwjAQRM/6FUtOCia2sXowBArevKofENIQI+luMVtEv954dZjjezMYXkUNWCQG/ihPo4GJCieM0nlPM7IVDwrP2Bd/T/mtKifMcpEpxh80OHZWdN1BGBhdyrJOTNkl5CKZrJhLqEaP/zcCtnBxvIE9nGcE3egWWn3Uu1qQTQ2sbtfT+guuRDPD
Cancel-Lock: sha1:kYZYVr3uaxF33RaFH9zDZloGOTs=
X-Abuse-Contact: "abuse@dns-netz.com"
X-Newsreader: trn 4.0-test76 (Apr 2, 2001)
 by: joe...@schily.net - Sat, 5 Jun 2021 12:23 UTC

In article <s9ddpc$1omsk$1@news.xmission.com>,
Kenny McCormack <gazelle@shell.xmission.com> wrote:

>What bash aliases do not support - and this is what severely limits their
>usability - is embedded arguments in the alias. I.e., in the above alias,
>you couldn't make the "hello" part a runtime argument.

Well recent versions of the Bourne Shell support aliases with arguments in
case you combine the aliases with the shell builtin "dosh".

Use e.g.:

dosh 'command "$@"' cmdname

as the alias replacement and this causes the Bourne Shell to run an intrisic
one line shell "script" that of course permits to use argument parameters.

Se alias(1) and dosh(1) documentation in the Bourne Shel man page:

http://schilytools.sourceforge.net/man/man1/bosh.1.html

--
EMail:joerg@schily.net Jörg Schilling D-13353 Berlin
Blog: http://schily.blogspot.com/
URL: http://cdrecord.org/private/ http://sourceforge.net/projects/schilytools/files/

Re: Simple (?) Script Question

<s9fu9d$1q0nd$1@news.xmission.com>

  copy mid

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

  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: Simple (?) Script Question
Date: Sat, 5 Jun 2021 13:30:21 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <s9fu9d$1q0nd$1@news.xmission.com>
References: <alpine.DEB.2.11.2106031544340.8335@bfjrtb.sbkinyyrl.arg> <20210604154709.2d526bc9@nx-74205> <s9ddpc$1omsk$1@news.xmission.com> <s9fqbr$du$1@news.dns-netz.com>
Injection-Date: Sat, 5 Jun 2021 13:30:21 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="1901293"; 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, 5 Jun 2021 13:30 UTC

In article <s9fqbr$du$1@news.dns-netz.com>, <joerg@schily.net> wrote:
>In article <s9ddpc$1omsk$1@news.xmission.com>,
>Kenny McCormack <gazelle@shell.xmission.com> wrote:
>
>>What bash aliases do not support - and this is what severely limits their
>>usability - is embedded arguments in the alias. I.e., in the above alias,
>>you couldn't make the "hello" part a runtime argument.
>
>Well recent versions of the Bourne Shell support aliases with arguments in

Who cares???

Irrelevant. Off topic. Noise.

This thread has nothing to do with any "Bourne" shell.

Amazing that nobody seems to get that.

And as I've already said more than a few times, tcsh aliases (which *are*
relevant to this thread) *do* support inline arguments - and always have.

--
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/Voltaire

Re: Simple (?) Script Question

<s9g0mj$q2p$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: mortons...@gmail.com (Ed Morton)
Newsgroups: comp.unix.shell
Subject: Re: Simple (?) Script Question
Date: Sat, 5 Jun 2021 09:11:30 -0500
Organization: A noiseless patient Spider
Lines: 43
Message-ID: <s9g0mj$q2p$1@dont-email.me>
References: <alpine.DEB.2.11.2106031544340.8335@bfjrtb.sbkinyyrl.arg>
<s9d02d$rqf$1@dont-email.me> <against-universals@bongo-ra.co>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 5 Jun 2021 14:11:31 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="313ca7d4b116d9870b8b1040938ebe52";
logging-data="26713"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/nwNSe7Brmq5x7sMqLJQqt"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:/8oCgPWps+2zEB9P+Ib0gLN0hqg=
In-Reply-To: <against-universals@bongo-ra.co>
X-Antivirus-Status: Clean
Content-Language: en-US
X-Antivirus: Avast (VPS 210605-2, 06/05/2021), Outbound message
 by: Ed Morton - Sat, 5 Jun 2021 14:11 UTC

On 6/4/2021 7:13 AM, Spiros Bousbouras wrote:
> On Fri, 4 Jun 2021 05:42:22 -0500
> Ed Morton <mortonspam@gmail.com> wrote:
>> On 6/3/2021 3:08 PM, Glenn P., wrote:
>>> I'm on a Unix shell account using TCSH and when changing
>>> directories have been first issuing a "cd" comnand, followed
>>> by an "ls" comnand.
>>>
>>> I'd like to write a script that combines these two so that I
>>> only need to enter ONE command and not two.
>>>
>>> This is what I've tried:
>>>
>>> !/bin/tcsh
>>> cd $*
>>> clear
>>> /bin/ls -AFog | more
>>
>> Don't write scripts using [t]csh. See
>> https://www.grymoire.com/Unix/CshTop10.txt or just google it:
>> https://www.google.com/search?q=csh+why+not
>
> I have written dozens of scripts using tcsh and it works fine. That's not
> to say that for some programming tasks another programming language might not
> be better suited

It's also not to say that for THOSE programming tasks another
programming language might not have been better suited. I expect we're
all spoiled for examples of cases where we've created something that
"worked fine" and then later discovered there was a better way to do it.

I expect there are some small tasks that you can write a [t]csh script
for and it won't be terrible but there's just no point in learning to do
so when you can learn to write those scripts in a bourne-derived shell
and that will better prepare you for the many other tasks you will have
to do later and won't lure you into trying to also do those tasks in [t]csh.

Ed.

> for some appropriate definition of "better"
> for some appropriate definition of "appropriate" !
>

Re: Simple (?) Script Question

<20210605074321.605@kylheku.com>

  copy mid

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

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: 563-365-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.unix.shell
Subject: Re: Simple (?) Script Question
Date: Sat, 5 Jun 2021 15:04:33 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 56
Message-ID: <20210605074321.605@kylheku.com>
References: <alpine.DEB.2.11.2106031544340.8335@bfjrtb.sbkinyyrl.arg>
<s9d29d$1ob40$1@news.xmission.com> <20210604154709.2d526bc9@nx-74205>
<s9ddpc$1omsk$1@news.xmission.com> <s9fqbr$du$1@news.dns-netz.com>
Injection-Date: Sat, 5 Jun 2021 15:04:33 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="733a49ddd7636489a8a615527bb3a9e2";
logging-data="19348"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19PfprEAyPBuCced4ENgGYfax9YX7d5ncQ="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:HE4Q0CYF7LaY1+MbOCglnOTb/Hc=
 by: Kaz Kylheku - Sat, 5 Jun 2021 15:04 UTC

On 2021-06-05, joerg@schily.net <joerg@schily.net> wrote:
> In article <s9ddpc$1omsk$1@news.xmission.com>,
> Kenny McCormack <gazelle@shell.xmission.com> wrote:
>
>>What bash aliases do not support - and this is what severely limits their
>>usability - is embedded arguments in the alias. I.e., in the above alias,
>>you couldn't make the "hello" part a runtime argument.
>
> Well recent versions of the Bourne Shell support aliases with arguments in
> case you combine the aliases with the shell builtin "dosh".

"Aliases with arguments" is something that need not exist, given that
there are functions.

Or else it can be a syntactic sugar that expands to a function
definition.

Here is my 60 second implementation that should work in any Bash
going back to 1990-something..

myalias()
{ local cmd=$1
local body=$2
eval "function $cmd() { $body; }"
}

Demo:

bash$ myalias thirdarg 'echo $3'
bash$ thirdarg 1 2 3 4
3

A disadvantage of the above 60 second implementation is that if $@, $* or
$<n> is not meentioned, we would like the command to implicitly
take the "$@" arguments.

Also, an invocation of $name could be implicitly
translated to "command $name".

If those features are provided, we can do:

myalias ls 'ls --color'

which will translate to:

ls()
{
command ls --color "$@"
}

and then even the existing alias feature becomes more or less redundant.

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

Re: Simple (?) Script Question

<20210605083810.951@kylheku.com>

  copy mid

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

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: 563-365-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.unix.shell
Subject: Re: Simple (?) Script Question
Date: Sat, 5 Jun 2021 17:19:27 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 107
Message-ID: <20210605083810.951@kylheku.com>
References: <alpine.DEB.2.11.2106031544340.8335@bfjrtb.sbkinyyrl.arg>
<s9d29d$1ob40$1@news.xmission.com> <20210604154709.2d526bc9@nx-74205>
<s9ddpc$1omsk$1@news.xmission.com> <s9fqbr$du$1@news.dns-netz.com>
<20210605074321.605@kylheku.com>
Injection-Date: Sat, 5 Jun 2021 17:19:27 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="733a49ddd7636489a8a615527bb3a9e2";
logging-data="22761"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/EPvbRW6mgGJFeY+c1TjH09LusPI7vyWs="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:E2+IJdIeLmbxMW6dns7e7hQmJ2M=
 by: Kaz Kylheku - Sat, 5 Jun 2021 17:19 UTC

On 2021-06-05, Kaz Kylheku <563-365-8930@kylheku.com> wrote:
> On 2021-06-05, joerg@schily.net <joerg@schily.net> wrote:
>> In article <s9ddpc$1omsk$1@news.xmission.com>,
>> Kenny McCormack <gazelle@shell.xmission.com> wrote:
>>
>>>What bash aliases do not support - and this is what severely limits their
>>>usability - is embedded arguments in the alias. I.e., in the above alias,
>>>you couldn't make the "hello" part a runtime argument.
>>
>> Well recent versions of the Bourne Shell support aliases with arguments in
>> case you combine the aliases with the shell builtin "dosh".
>
> "Aliases with arguments" is something that need not exist, given that
> there are functions.
>
> Or else it can be a syntactic sugar that expands to a function
> definition.
>
> Here is my 60 second implementation that should work in any Bash
> going back to 1990-something..
>
> myalias()
> {
> local cmd=$1
> local body=$2
> eval "function $cmd() { $body; }"
> }
>
> Demo:
>
> bash$ myalias thirdarg 'echo $3'
> bash$ thirdarg 1 2 3 4
> 3
>
> A disadvantage of the above 60 second implementation is that if $@, $* or
> $<n> is not meentioned, we would like the command to implicitly
> take the "$@" arguments.
>
> Also, an invocation of $name could be implicitly
> translated to "command $name".

Five minute version:

startswith()
{ local prefix=$1
local string=$2
local remove=${string#"$prefix"}

[ "$remove" != "$string" ]
}

contains()
{ local infix=$1
local string=$2
local remove=${string#*"$infix"}

[ "$remove" != "$string" ]
}

myalias()
{ local cmd=$1
local body=$2
local prefix=''
local suffix=' "$@"'

if startswith "$cmd " "$body" ; then
prefix='command '
fi

if contains '$@' "$body" || contains '$*' "$body" ; then
suffix=''
fi

eval "function $cmd() { $prefix$body$suffix; }"
}

A few expansion tests:

$ myalias ls 'ls --color'
$ set | grep -A 3 '^ls'
ls ()
{ command ls --color "$@"
}

$ myalias ls 'ls --color "$*"'
$ set | grep -A 3 '^ls'
ls ()
{
command ls --color "$*"
}

$ myalias ls 'foo --color "$*"'
$ set | grep -A 3 '^ls'
ls ()
{
foo --color "$*"
}

Aliases seem to guard against mutual recursion; myalias doesn't.

If wee define 'alias foo=bar; alias bar=foo`, there is no runaway
behavior in executing either foo or bar. Not sure how valuable
that is in practical terms.

Re: Simple (?) Script Question

<s9geh9$6jk$1@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: jmc...@jmclin1.hsd1.ma.comcast.net (John McCue)
Newsgroups: comp.unix.shell
Subject: Re: Simple (?) Script Question
Date: Sat, 5 Jun 2021 18:07:37 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 17
Message-ID: <s9geh9$6jk$1@dont-email.me>
References: <alpine.DEB.2.11.2106031544340.8335@bfjrtb.sbkinyyrl.arg> <slrnsbilp4.23hf.naddy@lorvorc.mips.inka.de>
Reply-To: jmclnx@SPAMisBADgmail.com
Injection-Date: Sat, 5 Jun 2021 18:07:37 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="f8cbf269e394b319202b4027cf3c88e8";
logging-data="6772"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX192b9T+Ap6zDiciY9sR7Atv"
User-Agent: tin/2.4.3-20181224 ("Glen Mhor") (UNIX) (Linux/4.4.261 (x86_64))
Cancel-Lock: sha1:Bv+D+rNAZ4rTdhyTO7AqNFZ0DMI=
X-OS-Version: Slackware 14.2 x86_64
 by: John McCue - Sat, 5 Jun 2021 18:07 UTC

Christian Weisgerber <naddy@mips.inka.de> wrote:
> On 2021-06-03, Glenn P., <C128UserDELETE-THIS@FVI.Net> wrote:
>
>> !/bin/tcsh
>> cd $*
>> clear
>> /bin/ls -AFog | more
<snip>
>
> % alias cdls 'cd \!:1 ; clear ; /bin/ls -AFog | more'

I never thought of having such a command to do a cd/ls.

I am kind of glad the OP asked for one, added your alias
to my ~/.tcshrc but replaced '| more' with a '; pwd' :)

Re: Simple (?) Script Question

<s9gf68$6jk$2@dont-email.me>

  copy mid

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

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: jmc...@jmclin1.hsd1.ma.comcast.net (John McCue)
Newsgroups: comp.unix.shell
Subject: Re: Simple (?) Script Question
Date: Sat, 5 Jun 2021 18:18:48 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <s9gf68$6jk$2@dont-email.me>
References: <alpine.DEB.2.11.2106031544340.8335@bfjrtb.sbkinyyrl.arg> <20210604114734.1675996c@nx-74205> <s9ct3j$1o7gm$1@news.xmission.com> <20210604124104.28f8045e@nx-74205> <s9d29d$1ob40$1@news.xmission.com>
Reply-To: jmclnx@SPAMisBADgmail.com
Injection-Date: Sat, 5 Jun 2021 18:18:48 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="f8cbf269e394b319202b4027cf3c88e8";
logging-data="6772"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Ci1JvjsRUQRe8Sz+mKgfy"
User-Agent: tin/2.4.3-20181224 ("Glen Mhor") (UNIX) (Linux/4.4.261 (x86_64))
Cancel-Lock: sha1:tkpm7RQglNr6BsURtR9KISIf8sY=
X-OS-Version: Slackware 14.2 x86_64
 by: John McCue - Sat, 5 Jun 2021 18:18 UTC

Kenny McCormack <gazelle@shell.xmission.com> wrote:
> In article <20210604124104.28f8045e@nx-74205>,
> Aragorn <thorongil@telenet.be> wrote:
> ...
<snip>
>
> tcsh doesn't have shell functions.

Since what should have been a simple thread went off the
rails, I will add to the crazyness :)

> You might as well be recommending pink unicorns.
> tcsh doesn't have those either.

Well as a long time tcsh user, I have actually see pink
unicorns when using tcsh, but not other shells.

But that is after a long day/night session of analyzing
server logs from work and hitting the heavy stuff.

Pages:12
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor