Article View: comp.unix.shell
Article #4004Re: Bash equivalent of cmd /k switch
From: Nate Eldredge
Date: Wed, 03 Jun 2009 01:24
Date: Wed, 03 Jun 2009 01:24
20 lines
2082 bytes
2082 bytes
David Schwartz <davids@webmaster.com> writes:
> On Jun 2, 1:56�pm, Nate Eldredge <n...@vulcan.lan> wrote:
>
>> You could write your command to a file, and use --rcfile to point to
>> it. �But I'm having a hard time understanding why you want to do this;
>> most of the things I can imagine to do with this have better ways of
>> doing them. �What's your goal here?
>
> My guess would be that he wants to set up the shell in a special way.
> Maybe he wants to set environment variables, the prompt, the current
> working directory, and so on. This way, he can drop the user into a
> shell especially configured for some application.
In which case, one could just set the environment variables (including
PSn), change the directory, etc, before invoking the shell. One could
do this manually with chdir, putenv, etc, after fork and before exec, or
just do something lazier like
system("cd /some/dir; PS1=\"COMMAND>\"; MYVAR=MYVALUE; export PS1 MYVAR; bash");
Technical Details
Message-ID:
<86prdmaz4e.fsf@vulcan.lan>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!npeer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post02.iad.highwinds-media.com!newsfe20.iad.POSTED!4570aeb9!not-for-mailReferences:
<c7e2ac57-0e67-4727-a1ca-f5e4adea3803@r16g2000vbn.googlegroups.com> <86eiu2cq2e.fsf@vulcan.lan> <0d67cc76-a21f-40d0-a44f-16df03f78337@t10g2000vbg.googlegroups.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 4d82dd0a1,dfab991ae69ee2e X-Google-Attributes: gid4d82dd0a1,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!npeer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post02.iad.highwinds-media.com!newsfe20.iad.POSTED!4570aeb9!not-for-mail Newsgroups: comp.unix.shell,comp.unix.programmer,gnu.bash Subject: Re: Bash equivalent of cmd /k switch References: <c7e2ac57-0e67-4727-a1ca-f5e4adea3803@r16g2000vbn.googlegroups.com> <86eiu2cq2e.fsf@vulcan.lan> <0d67cc76-a21f-40d0-a44f-16df03f78337@t10g2000vbg.googlegroups.com> From: Nate Eldredge <nate@vulcan.lan> User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.3 (berkeley-unix) Message-ID: <86prdmaz4e.fsf@vulcan.lan> Cancel-Lock: sha1:14ftr/tJIPULGOcFLk9o9xbC9vU= MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Lines: 20 X-Complaints-To: abuse2@dslextreme.com NNTP-Posting-Date: Wed, 03 Jun 2009 01:24:04 UTC Organization: DSL Extreme Date: Tue, 02 Jun 2009 18:24:01 -0700