Article View: comp.unix.shell
Article #4006Re: Bash equivalent of cmd /k switch
From: Ben Finney
Date: Wed, 03 Jun 2009 03:56
Date: Wed, 03 Jun 2009 03:56
40 lines
2917 bytes
2917 bytes
(Ben, any chance you could set your full name in the From field of your messages? It would make discussions like this less confusing.) Ben <bgold12@gmail.com> writes: > On Windows, cmd.exe has the /k switch, which lets you execute a > command given by a command-line argument, and then the shell remains > open after finishing the execution of the command. Note that ‘cmd.exe’ is a program that gives a windowed terminal emulator, and it is that terminal emulator that remains after the commands within it have ended. > I know bash has -c which lets you execute a command given by a > command-line argument, but then the shell closes after finishing the > command The ‘bash’ program, on the other hand, has nothing to do with providing a terminal emulator; it runs within a terminal provided by something else. > (this is analogous to the cmd.exe /c switch). Analogous, but not helpful in this case. The two jobs of “terminal emulator” and “command shell” are separate on Unix, but conflated on Windows. > My question is, is there a bash equivalent of the cmd.exe /k switch > that can be used to execute a command and then remain open? Not in bash (or any shell), no. What you want is to investigate how your terminal emulator can do this (e.g. by reading the man page for ‘xterm(1)’, ‘gnome-terminal(1)’, ‘rxvt(1)’, or whichever terminal emulator you choose). -- \ “Science shows that belief in God is not only obsolete. It is | `\ also incoherent.” —Victor J. Stenger, 2001 | _o__) | Ben Finney
Technical Details
Message-ID:
<87prdmq8aj.fsf@benfinney.id.au>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!feeder.news-service.com!xlned.com!feeder3.xlned.com!feeder.erje.net!news.mixmin.net!not-for-mailReferences:
<c7e2ac57-0e67-4727-a1ca-f5e4adea3803@r16g2000vbn.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,UTF8 Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!feeder.news-service.com!xlned.com!feeder3.xlned.com!feeder.erje.net!news.mixmin.net!not-for-mail From: Ben Finney <bignose+hates-spam@benfinney.id.au> Newsgroups: comp.unix.shell,comp.unix.programmer,gnu.bash Subject: Re: Bash equivalent of cmd /k switch Date: Wed, 03 Jun 2009 13:56:52 +1000 Organization: Mixmin Lines: 40 Message-ID: <87prdmq8aj.fsf@benfinney.id.au> References: <c7e2ac57-0e67-4727-a1ca-f5e4adea3803@r16g2000vbn.googlegroups.com> NNTP-Posting-Host: acdf78d43b5a0374c5e005f2d6325960 Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Complaints-To: abuse@mixmin.net NNTP-Posting-Date: Wed, 3 Jun 2009 03:57:03 +0000 (UTC) X-Public-Key-Fingerprint: 9CFE 12B0 791A 4267 887F 520C B7AC 2E51 BD41 714B Cancel-Lock: sha1:6lXRLD0hgTqO2rxzkv+4dWWucrE= X-Public-Key-ID: 0xBD41714B User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.3 (gnu/linux) X-Public-Key-URL: http://www.benfinney.id.au/contact/bfinney-gpg.asc X-Post-From: Ben Finney <bignose+hates-spam@benfinney.id.au>