From owner-freebsd-questions@freebsd.org Sat Oct 28 01:58:05 2017 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A1E5EE57291 for ; Sat, 28 Oct 2017 01:58:05 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mailrelay13.qsc.de (mailrelay13.qsc.de [212.99.187.253]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.antispameurope.com", Issuer "TeleSec ServerPass DE-2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 2C2BC835DC for ; Sat, 28 Oct 2017 01:58:04 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mx01.qsc.de ([213.148.129.14]) by mailrelay13.qsc.de; Sat, 28 Oct 2017 03:57:46 +0200 Received: from r56.edvax.de (port-92-195-74-193.dynamic.qsc.de [92.195.74.193]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx01.qsc.de (Postfix) with ESMTPS id 8C3B23CBF9; Sat, 28 Oct 2017 03:57:44 +0200 (CEST) Received: from r56.edvax.de (localhost [127.0.0.1]) by r56.edvax.de (8.14.5/8.14.5) with SMTP id v9S1vgld005188; Sat, 28 Oct 2017 03:57:43 +0200 (CEST) (envelope-from freebsd@edvax.de) Date: Sat, 28 Oct 2017 03:57:42 +0200 From: Polytropon To: Ian Smith Cc: Carl Johnson , freebsd-questions@freebsd.org Subject: Re: A request to segregate man pages for shell built-ins Message-Id: <20171028035742.8a0e909d.freebsd@edvax.de> In-Reply-To: <20171027232555.W40402@sola.nimnet.asn.au> References: <20171027021115.A40402@sola.nimnet.asn.au> <20171026214620.bf8fcbf2.freebsd@edvax.de> <20171027232555.W40402@sola.nimnet.asn.au> Reply-To: Polytropon Organization: EDVAX X-Mailer: Sylpheed 3.1.1 (GTK+ 2.24.5; i386-portbld-freebsd8.2) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-cloud-security-sender: freebsd@edvax.de X-cloud-security-recipient: freebsd-questions@freebsd.org X-cloud-security-Virusscan: CLEAN X-cloud-security-disclaimer: This E-Mail was scanned by E-Mailservice on mailrelay13.qsc.de with 7E5786835B3 X-cloud-security-connect: mx01.qsc.de[213.148.129.14], TLS=1, IP=213.148.129.14 X-cloud-security: scantime:.1515 X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Oct 2017 01:58:05 -0000 On Fri, 27 Oct 2017 23:56:15 +1100 (EST), Ian Smith wrote: > On Thu, 26 Oct 2017 21:46:20 +0200, Polytropon wrote: > > On Fri, 27 Oct 2017 03:02:17 +1100 (EST), Ian Smith wrote: > > > In freebsd-questions Digest, Vol 699, Issue 4, Message: 3 > > > On Wed, 25 Oct 2017 15:16:47 +0200 Polytropon wrote: > [...] > > Oh, and nobody with a sane mind writes shell scripts in C Shell. > > Of course I've done it. ;-) > > Agreed, but I guess I'm not quite so insane :) For one thing, I find > csh's redirections confusing and less complete, so even interactively > I'll do things to avoid csh syntax like (as a wild example): > > % sh -c 'for i in a b c; do echo $i; sleep 2; done 2>&1 >file' Yes, rediretion is a problem, and there are more (if - then - endif, foreach, set, probably quoting issues, etc.). The C shell simply isn't that great for scripting. But under certain curcumstances and preferences, its dialog behaviour is more convenient than that of bash in its stock configuration. There is a nice article about it: "Csh Programming Considered Harmful", to be found here: https://www-uxsup.csx.cam.ac.uk/misc/csh.html I would definitely _not_ write a script again for the C shell, but the one (!) I wrote still works, so I don't think it should be rewritten - "nyet kaputnik, nyet reparaturowka". ;-) > > > > % which echo > > > > echo: shell built-in command. > > > > > > > > $ which echo > > > > /bin/echo > > > > > > Again, despite that, echo _is_ builtin to sh(1) - and has more options. > > > > That is correct (even though sh's "which echo" reports the binary); > > sh's echo supports escape sequences using the -e option, while the > > binary doesn't. > > However, as Carl Johnson since posted: > > > 'Which' is an external for sh so it can't show builtin commands. Sh has > > the builtin 'type' command which is the equivalent of 'which' for csh. > > which was news to me. So I tried something: > > % sh > $ alias > $ type type > type is a shell builtin > $ type which > which is a tracked alias for /usr/bin/which > $ > $ alias which=type > $ which which > which is an alias for type > $ type which > which is an alias for type > $ which test > test is a shell builtin > $ which echo > echo is a shell builtin > $ > $ unalias which > $ which which > /usr/bin/which > $ which echo > /bin/echo > $ which test > /bin/test > > So thanks for that, Carl .. That's a really interesting experiment. > > > Perhaps sh(1) could use a smarter 'which' that exposes its own builtins > > > such as these two more readily - but who dares mess with sh(1) ? :) > > > > Interactively? Probably only the poor souls dropped into > > maintenance mode (single user mode) without the ability to > > start a more comfortable interactive shell... ;-) > > Ability? Just choose '/bin/csh' on entry, or type 'csh' once in SUM? In worst case, the C shell might not be available. I actually have no idea how bad it must be, but it's possible that everything you have is the "dumb" /bin/sh, and you need to deal with that. You _never_ know what strange symptoms a damaged system could expose. So dealing with "all I have is this stupid shell" is one of the skills a good system administrator should have. :-) -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...