delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2022/03/23/03:21:46

X-Recipient: archive-cygwin AT delorie DOT com
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 548F13858401
Authentication-Results: sourceware.org; dmarc=none (p=none dis=none)
header.from=SystematicSw.ab.ca
Authentication-Results: sourceware.org;
spf=none smtp.mailfrom=systematicsw.ab.ca
X-Authority-Analysis: v=2.4 cv=frTP2X0f c=1 sm=1 tr=0 ts=623aca77
a=oHm12aVswOWz6TMtn9zYKg==:117 a=oHm12aVswOWz6TMtn9zYKg==:17
a=IkcTkHD0fZMA:10 a=uYT-Tk0qkVT609LjNaIA:9 a=QEXdDO2ut3YA:10
Message-ID: <a7492018-87f3-6b5b-5a8a-d1f36e2b11c1@SystematicSw.ab.ca>
Date: Wed, 23 Mar 2022 01:21:27 -0600
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.7.0
Subject: Re: Running a command in a specific directory
To: cygwin AT cygwin DOT com
References: <8034c9ba-8384-a239-faf8-e8376d6dbc2e AT gmail DOT com>
From: Brian Inglis <Brian DOT Inglis AT SystematicSw DOT ab DOT ca>
Organization: Systematic Software
In-Reply-To: <8034c9ba-8384-a239-faf8-e8376d6dbc2e@gmail.com>
X-CMAE-Envelope: MS4xfPydRU2c3z7+4iy8v7Y5ifpUqFF+Up5TcRFa37+0ptnDC2XgmhTuJOGXbVlXpXrTnX+C5+AhwXCug/dFy1hJ/+MjFNH9p/c6su68o1Nw9GeKa7TG21FL
Qdl+4nlMGWe+KeNlumdELge/d1CG3kk/jO4EL3d+rHXKRrCpwwzyD51ulscd1pd5n3aeSKxygsUX2izGD56k8gSlKOBaYAa0xUo=
X-Spam-Status: No, score=-1164.1 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS,
KAM_LAZY_DOMAIN_SECURITY, NICE_REPLY_A, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,
SPF_HELO_NONE, SPF_NONE, TXREP,
T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.4
X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on
server2.sourceware.org
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.29
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Unsubscribe: <https://cygwin.com/mailman/options/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=unsubscribe>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
Reply-To: cygwin AT cygwin DOT com
Errors-To: cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com>
X-MIME-Autoconverted: from base64 to 8bit by delorie.com id 22N7Lkvr011088

On 2022-03-22 16:35, Piotr Gliźniewicz wrote:
> I'm trying to run a command at a specific "Windows" path. Basically 
> something similar to what chere does for bash, but I want to execute ls 
> in bash for a specific directory. I've tried variations of what chere 
> leaves in the registry:
> C:\cygwin64\bin\bash.exe -c "/bin/xhere /bin/bash.exe '%L'"
> Adding simply `-c ls` didn't work.
> To start with something simpler I've launched bash and tried just to 
> guess what xhere want's, but I don't really know what's happening. I 
> couldn't find any help for xhere.
> /cygdrive/c
> $ /bin/xhere '/bin/bash.exe -c ls' d:
> /bin/xhere: line 38: [: too many arguments
> /bin/xhere: line 41: [: too many arguments
> /bin/xhere: line 64: [: too many arguments
> Starting /bin/bash.exe -c ls
> -/bin/bash: ls: command not found
> /cygdrive/c
> $ /bin/xhere "/bin/bash.exe -c ls" d:
> /bin/xhere: line 38: [: too many arguments
> /bin/xhere: line 41: [: too many arguments
> /bin/xhere: line 64: [: too many arguments
> Starting /bin/bash.exe -c ls
> -/bin/bash: ls: command not found
> Any hints, how to properly pass `/bin/bash.exe -c ls` to xhere?

$ file `which xhere`
/usr/bin/xhere: Bourne-Again shell script, ASCII text executable
$ head `which xhere`
#!/bin/bash
# Have to use bash; can't get ash to "exec -l"
# Separate script from chere to avoid need for argument parsing
#
# first arg is shell
# second arg is the path
...

Can't do that: xhere expects shell path /bin/*sh* and directory path and 
runs under bash so it can run exec -l to exec shell as login shell after 
cd dir.

Starting XWin Server from a shortcut uses:

C:\...\cygwin...\bin\run.exe --quote /bin/bash -l -c "cd; exec 
/bin/startxwin"

so you could base a commnad line on that.

You could also install and use Cygwin-X with a GUI file manager like 
PcManFM, or a text version like Midnight Commander (package mc).

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

This email may be disturbing to some readers as it contains
too much technical detail. Reader discretion is advised.
[Data in binary units and prefixes, physical quantities in SI.]

-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019