From: Max Nikulin <manikulin@gmail.com>
To: alain.cochard@unistra.fr
Cc: Leo Butler <Leo.Butler@umanitoba.ca>,
"emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: Re: bash source code block: problem after ssh commands
Date: Sat, 28 Oct 2023 12:22:39 +0700 [thread overview]
Message-ID: <f0786a1d-a9a6-4d9a-a10f-dca406e022d2@gmail.com> (raw)
In-Reply-To: <25916.238.191509.652552@gargle.gargle.HOWL>
On 28/10/2023 01:26, Alain.Cochard@unistra.fr wrote:
> bash -c "bash /path/to/file-containing-the-source-code.sh"
>
> Without the quotes, the 1st line is not executed either. NB: I get
> the same behavior with simply
Without quotes it means: execute shell script (just "bash" this case)
with "$0" set to "/path/to/file-containing-the-source-code.sh".
"/path/..." is ignored because shell script does not contain "$0". It is
a way to safely pass arguments to shell, however "$0" is confusing:
sh -c 'echo "arg0: $0"; echo args: "$@"' arg0 arg1 arg2
arg0: arg0
args: arg1 arg2
In this example "arg0: $0"; echo args: "$@"' has the same role as
"bash" in the cited command.
If you need to pass another variable into "sh -c" the use
var="/bin/sh"
sh -c 'ls -l "$1"' argv0-for-sh "$var"
Unsafe variant ("var" contain quotes): sh -c "ls -l '$var'". The same
warning is applicable to "emacs --eval "(func \"$var\")".
> or, after making the script executable with 'chmod +x':
>
> /path/to/file-containing-the-source-code.sh
Always add a shebang ("#!/bin/sh", "#!/bin/bash", etc.) to executable
scripts. A chance to face a bug is a shell is higher when it is left up
to the shell and the kernel what to do with files without shebangs.
Sorry, I have not tried to debug the original issue.
next prev parent reply other threads:[~2023-10-28 5:23 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-25 11:17 bash source code block: problem after ssh commands Alain.Cochard
2023-10-25 15:12 ` Leo Butler
2023-10-25 16:14 ` Alain.Cochard
2023-10-25 16:47 ` Leo Butler
2023-10-25 16:59 ` yaxp
2023-10-26 8:44 ` Ihor Radchenko
2023-10-26 13:23 ` Alain.Cochard
2023-10-26 13:44 ` Ihor Radchenko
2023-10-27 18:26 ` Alain.Cochard
2023-10-28 5:22 ` Max Nikulin [this message]
2023-10-30 10:50 ` Bruno Barbier
2023-11-06 13:32 ` Ihor Radchenko
2023-11-06 18:25 ` Matt
2023-11-07 8:55 ` Ihor Radchenko
2023-11-08 19:41 ` Matt
2023-11-09 12:14 ` Ihor Radchenko
2023-11-09 17:48 ` Matt
2023-11-15 16:32 ` Matt
2023-11-15 18:04 ` Matt
2023-11-16 9:32 ` Ihor Radchenko
2023-11-16 19:03 ` Matt
2023-11-16 19:46 ` Alain.Cochard
2023-11-16 20:54 ` Matt
2023-11-17 9:22 ` Ihor Radchenko
2023-11-17 9:55 ` Alain.Cochard
2023-11-17 10:17 ` Ihor Radchenko
2023-11-17 15:32 ` Leo Butler
2023-11-17 15:47 ` Bruno Barbier
2023-11-18 10:37 ` Ihor Radchenko
2023-11-21 19:01 ` Bruno Barbier
2023-11-22 17:06 ` Max Nikulin
2023-11-19 4:17 ` Non-emacs shell (Re: bash source code block: problem after ssh commands) Max Nikulin
2023-11-21 15:33 ` Bruno Barbier
2023-11-18 8:04 ` bash source code block: problem after ssh commands Max Nikulin
2023-11-18 10:43 ` Ihor Radchenko
2023-11-18 16:18 ` Max Nikulin
2023-11-17 22:07 ` Matt
2023-11-18 3:11 ` Forget about "bash -c bash file.sh" (Re: bash source code block: problem after ssh commands) Max Nikulin
2023-11-18 8:11 ` Matt
2023-11-18 8:29 ` Bruno Barbier
2023-11-18 8:43 ` Matt
2023-11-18 8:54 ` Bruno Barbier
2023-11-18 9:09 ` Matt
2023-11-18 9:11 ` Bruno Barbier
2023-11-18 10:47 ` Ihor Radchenko
2023-11-18 8:19 ` bash source code block: problem after ssh commands Bruno Barbier
2023-11-18 9:02 ` Matt
2023-11-18 15:51 ` Matt
2023-10-26 14:44 ` Russell Adams
2023-10-27 11:47 ` Alain.Cochard
2023-11-06 18:01 ` Matt
2023-11-07 0:51 ` Alain.Cochard
2023-11-18 8:09 ` Max Nikulin
2023-11-18 8:36 ` Bruno Barbier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f0786a1d-a9a6-4d9a-a10f-dca406e022d2@gmail.com \
--to=manikulin@gmail.com \
--cc=Leo.Butler@umanitoba.ca \
--cc=alain.cochard@unistra.fr \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).