delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2022/06/26/11:10:47

X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0A7FB3856DDC
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1656256246;
bh=LAkYLzC5ggteRBlcvfL1fQyyDYeT6QXnFFDh0C8H/b0=;
h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post:
List-Help:List-Subscribe:From:Reply-To:From;
b=Il1LwNV7Qwkkh0mxhbQy5TeaUmiU+zykiP3rpHVJytS/c5E2+Iitimi7xTDxNBEUg
sVb0caJqnPZmLiV5mHhawFXBLT//ynjNfvL5vXv8ZW7ZSTx4nghc1ptzkGkf1VU0mZ
BeAzd2teQKPWHmTVfe4F6XxlGVNfS7j5GznAMrJs=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CBE053858294
X-SBRS-Extended: Low
X-IronPortListener: ces-out
X-IronPort-AV: E=Sophos;i="5.92,224,1650945600"; d="scan'208";a="306403885"
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
b=kLR7opEKaLH7xs3hyDJKUMIkaAAm7M1lfAvcdBOHsnBrMj+vEgpd1PkSyfQoPU6N2CEv6EdqgKe1tGyLSHBKWCDNQLvH80Ko47wi+rjll5YX5hVKz4xRP/ZZQyQMhC69lHkgNf9fR1+d8agzOc2BEJGbfkZHHuU4vHv9hdfvw3yw8u9kq5biO6xp/pfy7IoGtNTCMhJh3lGxz4Cw+Zg5544+yTxbPwcJVyiU4IvKAYmymq1LH6JZh/Di+bJJwjexzqXI2yaNz01ME9yvXdzEYxSzCBOafdcaRb+2Yq/IaZ0yxdTjz5o32HjV41EiBwl8tJunzEuVudaUIG42qlrBnA==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;
s=arcselector9901;
h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;
bh=XL2h9auaS5Ezt8z2+38cPrOogDXQ8A1Ab+bcNGAWQyI=;
b=kAb5eFPD61k03BQZPMp5FTqgM/BhQr/ltdiE4coYmEpARLUzFaOTYhJtdssfu76md5vjUnkH8VBSCLZ0TNinhpDjwXS7xRQZnvdhyxcZQF6+37ulDU0PQ5hYPV+1TRIGMetV0uCtJy0Scl/BHJijwI9CT192yCFUtw3CeFXIj1GmDhoUqFUTHNW2mHPt0J72A0zwfqO3h+dWFdseAOie4/KfbteNmC/xn7PlxqPIP1FvGF6WVyl5hc6hmbaLgI2Lu9XJ2mM7FkVKvDDFO4SPk4gQ7n5Q+v6eDf9NZT8VLMBBuHCZpkHvdbe9j+QdB0dU9B7nJkv8ikYxKMYVhUP0ug==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass
smtp.mailfrom=ncbi.nlm.nih.gov; dmarc=pass action=none
header.from=ncbi.nlm.nih.gov; dkim=pass header.d=ncbi.nlm.nih.gov; arc=none
To: "'cygwin AT cygwin DOT com'" <cygwin AT cygwin DOT com>
Subject: Cygwin's execlp() does not work with an empty $PATH element
Thread-Topic: Cygwin's execlp() does not work with an empty $PATH element
Thread-Index: AdiJbrs+rXZuHXNaTrCqY66Eq3KrXA==
Date: Sun, 26 Jun 2022 15:09:34 +0000
Message-ID: <DM8PR09MB7095965E449CC03DEE772338A5B69@DM8PR09MB7095.namprd09.prod.outlook.com>
Accept-Language: en-US
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
x-ms-publictraffictype: Email
x-ms-office365-filtering-correlation-id: b116c66c-e60a-40ac-50a0-08da5785e101
x-ms-traffictypediagnostic: PH0PR09MB8601:EE_
x-ms-exchange-senderadcheck: 1
x-ms-exchange-antispam-relay: 0
x-microsoft-antispam: BCL:0;
x-microsoft-antispam-message-info: gtlYj/TncT94Ok+qhcgREgx9ve8z18/0UMTf3j12A8VOYClxTz6tbqxTsE2iKp/NV7vEcjyx0g5oWE+LybNUjBkmuQ+9WZnpKmynZ+kLm290V/SP5Pkx+EeNK8ihcDND1MLvDqWnQIRScx584+wUCu7EsBE55Wf088AvSytTDpN8y9uqhjM2DMZQ+QrecpMs1ie2pGGbvAQ2Xjqjjs9ewBln3oI94WSA7g38wIII94o1R3LsJIXFTuRa0BFW5glrzfWPxXN8BI1UeKkjnl98J8PbDwD56st/1OOSwO3BKkNbq+SpAEZbUN2ff2RdEVKeFbLL05Vy0WosFCVT4ShBdZKJ5gXt43UGkmijXxhTzsWPJq297IyUOEHEFVLThUMhRF5Qv0r7mB9pTEXmoDBy38B2PRM63LpGMr0B3CE1mcWNaAqcEH0Kxfej7xpZ14xmTrOzEmdn9OBRGoxZlW7nEnzHtkxo3Ad2iwpPOU9tWbUb6baMvfL6eU3+ABVNNlOI/hA6yOqEbG+4rS8xBeUM2k3qxoYVRotOdN7nJvKd8VPF0LTN441V5u8WO64MvDkkFQz9HReczMU93CdJ2VCqB8W7WtlFXKUqZu12cJkd8k5XnzFsCHHm/n8fF1cKq+fckoiyWo1oQkO/ICBvZ9m8vLvJY+VHlb4D3BxkcPUWwmIHg+6VnUg8HFiXqz8EEL9Nw+5VETxJk46ki2Xbmbau+CVBLR5o0NV2pZaoHq28JVEYSPBfnupKVCx2mKUcicOWlI0MbmQBlX+d6tnMeZ4c4udfwjav7/XWiJ26Ur6+taORt9vYfnEzmhj58JVWZKJO57VZgkaK0w/XnoG6CA+ZlQ==
x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:;
IPV:NLI; SFV:NSPM; H:DM8PR09MB7095.namprd09.prod.outlook.com; PTR:; CAT:NONE;
SFS:(13230016)(4636009)(366004)(55016003)(6916009)(122000001)(38100700002)(38070700005)(2906002)(66446008)(8676002)(71200400001)(9686003)(64756008)(66946007)(66476007)(76116006)(186003)(8936002)(33656002)(86362001)(52536014)(5660300002)(26005)(498600001)(66556008)(7696005)(6506007)(21314003)(491001);
DIR:OUT; SFP:1102;
x-ms-exchange-antispam-messagedata-chunkcount: 1
x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?Ki6x9VwbOp5Yin/BMhkNBKPSJqC9Qi5QfHDs6gDXdu8upNAqBs9HMXflHI1H?=
=?us-ascii?Q?EzkvD1khY7+YnmXRy4/urgiaMVkRPurKaL2U3+bR/6pQV2lZa07Bn9VfnPYX?=
=?us-ascii?Q?BDyuuO3exT9QgZdXhGRRu+lSkuZep9SpP2RSkTE4IDxrrvgs+qYn5S3xf32d?=
=?us-ascii?Q?5fGlXMwOmreHKOMuw8SXfndSY+lN3B74klGjVvfYCROhXsvAVNgEajWCVTg+?=
=?us-ascii?Q?6PGJM/8BrOwKKUEMvrIHtgQn/ISZ18pvLhlZJxpVotlUuCGZdd05r42ZXXyi?=
=?us-ascii?Q?IjtTHiicNE1AJYnV5Zn7u8biwa9j9YC+Rh7OC5dd4zZoKyIQcc3MO66cyjmW?=
=?us-ascii?Q?Sr8VU/KQ3tpkKZqjie2VxDWtSL1ldzONyKny6M0L7G2/dVg+VO1Tbg/YtZOd?=
=?us-ascii?Q?y0pccAHsjL83G5dgJ4WCJ36PD++G05549CToYZYRH2zQgldY+KofMAC4DaHh?=
=?us-ascii?Q?Grgqw0Ca+f4ryh1yPgwBZb44AwI7wk8WZc7M5P+BXgHmpUQSsrcOlqhvoV+H?=
=?us-ascii?Q?LgIAHEmRoTP3efGHCkGZzr2vDON4qkgGsOgk0IV/Dz0/BjuKY16NCDX0pgCj?=
=?us-ascii?Q?4qFQiSPHTBWCvkkNBzsi3IPiooGtSAguU3R/Ky5DeNckTmpf7AmYrRf/APx3?=
=?us-ascii?Q?t22yRHGXjQ/JgYORKBOJSWcOHtm9f8BmvPzVUpMnBksizGa0O2GBgn2mIaet?=
=?us-ascii?Q?jP9Iq6KjBe3AZ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0
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: DM8PR09MB7095.namprd09.prod.outlook.com
X-MS-Exchange-CrossTenant-Network-Message-Id: b116c66c-e60a-40ac-50a0-08da5785e101
X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Jun 2022 15:09:34.3104 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 14b77578-9773-42d5-8507-251ca2dc2b06
X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR09MB8601
X-OriginatorOrg: ncbi.nlm.nih.gov
X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00, DKIM_SIGNED,
DKIM_VALID, DKIM_VALID_EF, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE,
T_SPF_HELO_PERMERROR autolearn=ham autolearn_force=no version=3.4.6
X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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-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>
From: "Lavrentiev, Anton \(NIH/NLM/NCBI\) \[C\] via Cygwin" <cygwin AT cygwin DOT com>
Reply-To: "Lavrentiev, Anton \(NIH/NLM/NCBI\) \[C\]" <lavr AT ncbi DOT nlm DOT nih DOT gov>
Sender: "Cygwin" <cygwin-bounces+archive-cygwin=delorie DOT com AT cygwin DOT com>

Hi all,

An empty PATH element (":xxx" or "xxx::xxx" or "xxx:") is to be considered as the current directory (from the very first days of Unix).

However, Cygwin does not seem to obey the rule.

Consider the following simple C program:

$ cat hello.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

int main(int argc, const char* argv[])
{
    if (argc < 2) {
        const char* prog = strrchr(argv[0], '/');
        if (!prog++)
           prog = argv[0];
        execlp(prog, prog, "Hello", NULL);  // execute just by the program name
        perror("exec");
        return 1;
    }
    printf("%s\n", argv[1]);
    return 0;
}

Now compare the execution on Linux and Cygwin:

Linux:

$ gcc -Wall -o hello hello.c
$ hello
bash: hello: command not found
$ ./hello
exec: No such file or directory
$ PATH=".:$PATH" ./hello
Hello
$ PATH=":$PATH" ./hello
Hello
$ PATH="${PATH}:" ./hello
Hello

Cygwin:

$ gcc -Wall -o hello hello.c
$ hello
-bash: hello: command not found
$ ./hello
exec: No such file or directory
$ PATH=".:$PATH" ./hello
Hello
$ PATH=":$PATH" ./hello
exec: No such file or directory
$ PATH="${PATH}:" ./hello
exec: No such file or directory

As you can see, the execution failed when an empty PATH element was added on Cygwin
(yet it was perfectly fine on Linux).

Anton Lavrentiev
Contractor NIH/NLM/NCBI


-- 
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