From owner-freebsd-questions@freebsd.org Sun Apr 5 20:26:08 2020 Return-Path: Delivered-To: freebsd-questions@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 78F3926A294 for ; Sun, 5 Apr 2020 20:26:08 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "mout.kundenserver.de", Issuer "TeleSec ServerPass Class 2 CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48wQD45Gj4z3CdL for ; Sun, 5 Apr 2020 20:25:56 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from r56.edvax.de ([178.5.91.239]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPA (Nemesis) id 1MtOT0-1j28Da0IAQ-00usgb; Sun, 05 Apr 2020 22:25:40 +0200 Date: Sun, 5 Apr 2020 22:25:39 +0200 From: Polytropon To: Jos Chrispijn Cc: freebsd-questions@freebsd.org Subject: Re: Calling sh from csh Message-Id: <20200405222539.f1774965.freebsd@edvax.de> In-Reply-To: <8a13c839-6e0c-8a6e-32bf-b4b42dfaff67@cloudzeeland.nl> References: <8a13c839-6e0c-8a6e-32bf-b4b42dfaff67@cloudzeeland.nl> 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-Provags-ID: V03:K1:5HSBJDDO7ga2LEu+NTltSwyB1C3EBtYiLLtTE1griGnaqFGrNtn z6U+GkVZtnegr9YNQLTSqiuz3OOuJBimHR5mQ9DPrMiPx1t5WhzWcDTliNf102VzcSnjBNL mzLdvFNzdRPkdQV6GFGbatLSpoukQfn5EMGq5X+/SuLI8BVttbyBVfnb22zA/51s05kaOmk Hf/i49qCMAaID9Xe3Lp8A== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1;V03:K0:qtnELbuiaK0=:Qo4AyHIaRBoCTwxMewxT3e q0BwfNPLuUoQSUPAcAnGKUaS0yoefqrWvTao4hLR+ThLrrFMe4f84d4bHuaqrEBw+S2/2Xb0C vS1lvCONcCodLCom/c4Mou2amFFzr+d57Cl6QkSIAouck4/7Alvc5oJQQfnhIHsP6E2MN8wJz 62klM3M9WKMBLLgRKGVwQ+rP7MgBIE+dnMF/jQW/cXZfE6/tu+WITHGbuWCB/x3sxnXVHKLeC 1PyLlJHmaV9a/G9CYyRcBNTa7Efy4MyPh0RhYBC59Wr/swv4xsUbhkrhM1qmQbGFx168s3X7D 5HtHoz1Xd3wJOfjfAiaBfn/J+4oGZMjWWHjW3+t4lhjb+0Mohu/vxu06sP3VKF2RRFQhNYwGN ssHZpKjxIbYiLE69lbE/32WNLk896R5RIyZQccsbsoHknPiddFV0MezJfy9899FzTGfVi0hE+ U+BcoZDUcwOJ5/WLrHYpVsSjpeSNf9c1nDF6QdU+RpcuOUjTeMeSTli5N0QZR108F4a0KHx8w ip07f6i7tvzw7JO+74fPnd4yvk74LMzHIfRv0FGIYl+S6JRu6GCQMyLFxA/SXcFpJobtNDVtl itiLrshMg+lDtELTkYcedFmBecRNihrCaE+pvXu7xYcQDIO68nHKys+J8f4zX6SuJM2A95H/t EAeOdwkGSjRdabxDer6J6z/ScZ5a4Wh8xhJ7UWmWbG0r4EaU0J7Nr+kpLjeh541AJYJd9QUEN kHkbPtGTy4kt/mUqB6przQx5msaSap8hjGFhO3iQbVVnNy3pFoNyZabWDtfhbAsEi/axJZmA+ 4kMWcwZ8eoBjgWJA7hjMu5/em7WRZz/02dsvi5IpwevyiInAVoMg/SQSfGlqwDRNOsGJHFJ X-Rspamd-Queue-Id: 48wQD45Gj4z3CdL X-Spamd-Bar: ++++ Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=none (mx1.freebsd.org: domain of freebsd@edvax.de has no SPF policy when checking 212.227.126.131) smtp.mailfrom=freebsd@edvax.de X-Spamd-Result: default: False [4.82 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; HAS_REPLYTO(0.00)[freebsd@edvax.de]; TO_DN_SOME(0.00)[]; MV_CASE(0.50)[]; HAS_ORG_HEADER(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; RECEIVED_SPAMHAUS_PBL(0.00)[239.91.5.178.khpj7ygk5idzvmvt5x4ziurxhy.zen.dq.spamhaus.net : 127.0.0.11]; RCVD_TLS_LAST(0.00)[]; R_DKIM_NA(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:8560, ipnet:212.227.0.0/16, country:DE]; ARC_NA(0.00)[]; REPLYTO_EQ_FROM(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[edvax.de]; AUTH_NA(1.00)[]; NEURAL_SPAM_MEDIUM(0.98)[0.982,0]; TO_MATCH_ENVRCPT_SOME(0.00)[]; NEURAL_SPAM_LONG(1.00)[0.996,0]; MID_CONTAINS_FROM(1.00)[]; RCVD_IN_DNSWL_NONE(0.00)[131.126.227.212.list.dnswl.org : 127.0.5.0]; R_SPF_NA(0.00)[]; RWL_MAILSPIKE_POSSIBLE(0.00)[131.126.227.212.rep.mailspike.net : 127.0.0.17]; RCVD_COUNT_TWO(0.00)[2]; IP_SCORE(0.44)[ip: (1.24), ipnet: 212.227.0.0/16(-1.15), asn: 8560(2.12), country: DE(-0.02)] X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 05 Apr 2020 20:26:08 -0000 On Sun, 5 Apr 2020 21:48:37 +0200, Jos Chrispijn wrote: > Can you tell me how I could find out if a shell script runs on csh or sh > and then execute it from within the right shell? If the shell script declares the required shell in the fist line, for example #!/bin/sh you can simply execute it (given that it has +x execution permission as required) by % ./scriptname and the correct interpreter will be used. You can also require bash (in case you're using extended non-sh functionality) by using #!/usr/local/bin/bash Similarly, executable scripts can call awk, perl or any other interpreter using the #! mechanism - you simply call the script by name, the correct interpreter will execute the script. In some cases, the filename extension .sh identifies a shell script as suitable for the sh (or sometimes bash) shell, so manually calling % sh scriptname.sh or % bash scriptname.sh will always work, no matter if a valid #! line is present. In case no #! is present and the filename has no extension, it's required to examine the actual content of the script in order to run the required interpreter. :-) -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...