From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 31587 invoked from network); 1 Jan 2024 20:00:24 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 1 Jan 2024 20:00:24 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1704139224; b=gR+6kRyse3oFjmKUiGEpwH2U0B9puZIpkdbajwFWVMDaS8xPJRve7E3Pr68njBSA+4nNO5Ecm4 yd7c95GOQshCvKcL3NktFzUA6BfN6hugsrtNHABgCNAQashxvT/HtycWNpMFc0hWmbrXo7CFal PVOd6ES+3CN9M9i0/TsekBCDOukjoFLV4iQ92PyuvlGvkIGD64chqmA5S5/+Bg8PfTdK+jequs lugfc3S3poy/dk0RCOiDl9qpg3KsHOCtdTixwvDM6QB8XnX05dJS3YNRH3aVBkHNIwpwSvwpiA t9DPBzOPvgovPzrIdSlRI3mgSMzjb1B6m1GnVsfh7Sb8qA==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (s1.jo-so.de) smtp.remote-ip=37.221.195.157; dmarc=none header.from=jo-so.de; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1704139224; bh=POaIX/BZOecSlRPfZdCdTWqbdP6zDcXKrzekY029HXs=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:MIME-Version:Message-ID:Date: Subject:Cc:To:From:DKIM-Signature; b=g85xBPuT9bI9ltFHafeF5oTfrrduYMYIF5RdPGKwaJ163o4iui3dpXk5ipR9mQ43M4DnDyLeeW wuGr/wS0k1Q3kqMwU69t17sZJ7SsLK9MAaJABjqobO5XPvZ+b9o1OynE9bBgDv7rHSaRlU0URR 4Wq8Y3RmGuNpdh4imClZ27ALT3rYzO+4M2RCC3QNnGqH3DNNVaBKF1UHGKqCBwHdtXviaDg+v6 f82PXf1Mu8kEDA0mbsYaIduqNZ1r473TEtjFRF2N3MUrCXNlnf6BYXA2Uqs9+nTGoZOAVmwq4e o6IUtkozB/7JmnKS/dreI/mgDjJXuhvfNVyJJLsWJ6O5iw==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Transfer-Encoding: MIME-Version:Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References; bh=TxfEud5CqUJdv20f/KNYW5+GFDHLqVKveirfw9Uik/A=; b=rs+CwzLdYWVQjvagoRqxi5jL/Y htfEuzJk2D8CyU+KjYc3ElMrDH2/9nSKv8hbwiZ5USpIggIrL4+n38ikmclsBJAIbJe8ClXa+qTkA FN3ZKBm+Sd/rThi24Pcgzq5/PplEECjUedaOfL8HOVD0RNYnS9tEoJx1AbFwArjdvO04g0SDNcUYC ai8g7xQ7BK8jawTdACfoSFCzQ3AIB1s8MR9Ohpa9LFNOxJbe+9wwWVCxJyCevNgRY0NfRF7Vm+B0d eb8aKZSqB7v6+Gt2MmF9zxvONX8L/mNkWZ2J2PB3lUEWLSdCZafYbrZ12VdJidddMLXuq21icTh+O RPewp/Xg==; Received: by zero.zsh.org with local id 1rKOSV-0003LB-Vt; Mon, 01 Jan 2024 20:00:24 +0000 Authentication-Results: zsh.org; iprev=pass (s1.jo-so.de) smtp.remote-ip=37.221.195.157; dmarc=none header.from=jo-so.de; arc=none Received: from s1.jo-so.de ([37.221.195.157]:59487) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_256_GCM_SHA384:256) id 1rKOSB-00033C-BQ; Mon, 01 Jan 2024 20:00:06 +0000 Received: from mail-relay (helo=jo-so.de) by s1.jo-so.de with local-bsmtp (Exim 4.96) (envelope-from ) id 1rKOS9-0040xq-2z for zsh-workers@zsh.org; Mon, 01 Jan 2024 21:00:01 +0100 Received: from joerg by zenbook.jo-so.de with local (Exim 4.97) (envelope-from ) id 1rKORw-00000001slE-185u; Mon, 01 Jan 2024 20:59:48 +0100 From: =?UTF-8?q?J=C3=B6rg=20Sommer?= To: zsh-workers@zsh.org Cc: =?UTF-8?q?J=C3=B6rg=20Sommer?= Subject: [PATCH] init.sourcehome: look in ~/.config/zsh for files Date: Mon, 1 Jan 2024 20:59:24 +0100 Message-ID: X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Seq: 52445 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: The [XDG Base Directory Specification][1] mandates to use the directory specified in the environment variable *$XDG_CONFIG_HOME* for config files. And it's rather more complex, because the variable *$XDG_CONFIG_DIRS* should be used, too. For most of the users a lookup of the config files in *~/.config/zsh* should be enough. Therefore, if a file is not found in the home directory, a second try to find it *without the leading dot* in *~/.config/zsh*. [1]: https://specifications.freedesktop.org/basedir-spec/basedir-spec-0.6.html --- Src/init.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Src/init.c b/Src/init.c index 799ad19f6..628a06e6c 100644 --- a/Src/init.c +++ b/Src/init.c @@ -1679,11 +1679,18 @@ sourcehome(char *s) } { + const int h_len = strlen(h); /* Let source() complain if path is too long */ - VARARR(char, buf, strlen(h) + strlen(s) + 2); + VARARR(char, buf, h_len + 13 + (strlen(s) - 1) + 1); sprintf(buf, "%s/%s", h, s); unqueue_signals(); - source(buf); + if (source(buf) == SOURCE_NOT_FOUND && h == home && s[0] == '.' + && ! EMULATION(EMULATE_SH|EMULATE_KSH)) { + queue_signals(); + sprintf(&buf[h_len + 1], ".config/zsh/%s", &s[1]); + unqueue_signals(); + source(buf); + } } } -- 2.43.0