Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Your mode of life will be changed to EBCDIC.


devel / comp.unix.shell / Abnormal HOME variable modification requirements.

SubjectAuthor
* Abnormal HOME variable modification requirements.hongy...@gmail.com
+* Re: Abnormal HOME variable modification requirements.Lew Pitcher
|`* Re: Abnormal HOME variable modification requirements.hongy...@gmail.com
| `* Re: Abnormal HOME variable modification requirements.Lew Pitcher
|  `* Getting a home directory in shell script (Was: Abnormal HOME variable modificatiKenny McCormack
|   +- Re: Getting a home directory in shell script (Was: Abnormal HOME variable modifiEli the Bearded
|   +- Re: Getting a home directory in shell script (Was: Abnormal HOMEhongy...@gmail.com
|   `* Re: Getting a home directory in shell script (Was: Abnormal HOMELew Pitcher
|    `* Re: Getting a home directory in shell script (Was: Abnormal HOMELew Pitcher
|     `* Re: Getting a home directory in shell scriptKeith Thompson
|      +* Re: Getting a home directory in shell scriptLew Pitcher
|      |`- Re: Getting a home directory in shell scripthongy...@gmail.com
|      `- Re: Getting a home directory in shell scripthongy...@gmail.com
+- Re: Abnormal HOME variable modification requirements.Grant Taylor
`* Re: Abnormal HOME variable modification requirements.Javier
 `- Re: Abnormal HOME variable modification requirements.hongy...@gmail.com

1
Abnormal HOME variable modification requirements.

<6e4cd80e-2513-4534-af7e-c9716c0b2e91n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4523&group=comp.unix.shell#4523

  copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:a37:9586:: with SMTP id x128mr19357256qkd.49.1635252468585;
Tue, 26 Oct 2021 05:47:48 -0700 (PDT)
X-Received: by 2002:a05:622a:1a0b:: with SMTP id f11mr24402590qtb.133.1635252468372;
Tue, 26 Oct 2021 05:47:48 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Tue, 26 Oct 2021 05:47:48 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=103.149.249.34; posting-account=kF0ZaAoAAACPbiK5gldhAyX5qTd3krV2
NNTP-Posting-Host: 103.149.249.34
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <6e4cd80e-2513-4534-af7e-c9716c0b2e91n@googlegroups.com>
Subject: Abnormal HOME variable modification requirements.
From: hongyi.z...@gmail.com (hongy...@gmail.com)
Injection-Date: Tue, 26 Oct 2021 12:47:48 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 35
 by: hongy...@gmail.com - Tue, 26 Oct 2021 12:47 UTC

I've written the following Emacs package debug script which can be
run by `$ bash /home/werner/.emacs.d/debug/.emacs.d/init.el`:

```emacs-lisp
#!/usr/bin/env bash
:;# $ realpath init.el
:;# /home/werner/.emacs.d/debug/.emacs.d/init.el
:; HOME=$(dirname $(dirname $(realpath -e $0))) proxychains-ng-socks5
/usr/local/bin/emacs -- "$@"; exit

;;Bootstrap straight
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el"
user-emacs-directory))
(bootstrap-version 5))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
(straight-use-package 'use-package)
(setq straight-use-package-by-default t)

(use-package company
:demand t
:hook
(after-init . global-company-mode))
```
But the `proxychains-ng-socks5` wrapper script relies on the normal HOME variable setting. How to solve this dilemma?

Regards,
HZ

Re: Abnormal HOME variable modification requirements.

<sl91cf$pr5$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4524&group=comp.unix.shell#4524

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: lew.pitc...@digitalfreehold.ca (Lew Pitcher)
Newsgroups: comp.unix.shell
Subject: Re: Abnormal HOME variable modification requirements.
Date: Tue, 26 Oct 2021 13:55:27 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 51
Message-ID: <sl91cf$pr5$1@dont-email.me>
References: <6e4cd80e-2513-4534-af7e-c9716c0b2e91n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 26 Oct 2021 13:55:27 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="816c93de529df6f5f7d1a6545b4b51fa";
logging-data="26469"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+8wnti6EejtcVppKq74o5Ow00lykjgd1Y="
User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508
git://git.gnome.org/pan2)
Cancel-Lock: sha1:ExIGFFv71/w0XYvbMpAxi5EYM30=
 by: Lew Pitcher - Tue, 26 Oct 2021 13:55 UTC

On Tue, 26 Oct 2021 05:47:48 -0700, hongy...@gmail.com wrote:

> I've written the following Emacs package debug script which can be
> run by `$ bash /home/werner/.emacs.d/debug/.emacs.d/init.el`:
>
> ```emacs-lisp
> #!/usr/bin/env bash
> :;# $ realpath init.el
> :;# /home/werner/.emacs.d/debug/.emacs.d/init.el
> :; HOME=$(dirname $(dirname $(realpath -e $0))) proxychains-ng-socks5
> /usr/local/bin/emacs -- "$@"; exit
>
> ;;Bootstrap straight
> (defvar bootstrap-version)
> (let ((bootstrap-file
> (expand-file-name "straight/repos/straight.el/bootstrap.el"
> user-emacs-directory))
> (bootstrap-version 5))
> (unless (file-exists-p bootstrap-file)
> (with-current-buffer
> (url-retrieve-synchronously
> "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
> 'silent 'inhibit-cookies)
> (goto-char (point-max))
> (eval-print-last-sexp)))
> (load bootstrap-file nil 'nomessage))
> (straight-use-package 'use-package)
> (setq straight-use-package-by-default t)
>
> (use-package company
> :demand t
> :hook
> (after-init . global-company-mode))
> ```
> But the `proxychains-ng-socks5` wrapper script relies on the normal HOME
> variable setting. How to solve this dilemma?

Well, you /could/ derive your version of HOME differently. Yes, let's go
with that.

Initially, HOME is derived from the 6th field in the user's
/etc/passwd entry. You could
- use whoami(1) to determine the username
- use grep(1) and cut(1) (alternately, just awk(1) )to parse /etc/passwd
and extract the home directory of the selected username
- use that extracted home directory value to set your HOME variable

HTH
--
Lew Pitcher
"In Skills, We Trust"

Re: Abnormal HOME variable modification requirements.

<175fb530-8edb-4216-9d67-c42b1fbd908fn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4525&group=comp.unix.shell#4525

  copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:a0c:e909:: with SMTP id a9mr18528197qvo.2.1635261242487;
Tue, 26 Oct 2021 08:14:02 -0700 (PDT)
X-Received: by 2002:a05:622a:5c8:: with SMTP id d8mr25344643qtb.63.1635261242308;
Tue, 26 Oct 2021 08:14:02 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Tue, 26 Oct 2021 08:14:02 -0700 (PDT)
In-Reply-To: <sl91cf$pr5$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=143.198.81.115; posting-account=kF0ZaAoAAACPbiK5gldhAyX5qTd3krV2
NNTP-Posting-Host: 143.198.81.115
References: <6e4cd80e-2513-4534-af7e-c9716c0b2e91n@googlegroups.com> <sl91cf$pr5$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <175fb530-8edb-4216-9d67-c42b1fbd908fn@googlegroups.com>
Subject: Re: Abnormal HOME variable modification requirements.
From: hongyi.z...@gmail.com (hongy...@gmail.com)
Injection-Date: Tue, 26 Oct 2021 15:14:02 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 52
 by: hongy...@gmail.com - Tue, 26 Oct 2021 15:14 UTC

On Tuesday, October 26, 2021 at 9:55:32 PM UTC+8, Lew Pitcher wrote:
> On Tue, 26 Oct 2021 05:47:48 -0700, hongy...@gmail.com wrote:
>
> > I've written the following Emacs package debug script which can be
> > run by `$ bash /home/werner/.emacs.d/debug/.emacs.d/init.el`:
> >
> > ```emacs-lisp
> > #!/usr/bin/env bash
> > :;# $ realpath init.el
> > :;# /home/werner/.emacs.d/debug/.emacs.d/init.el
> > :; HOME=$(dirname $(dirname $(realpath -e $0))) proxychains-ng-socks5
> > /usr/local/bin/emacs -- "$@"; exit
> >
> > ;;Bootstrap straight
> > (defvar bootstrap-version)
> > (let ((bootstrap-file
> > (expand-file-name "straight/repos/straight.el/bootstrap.el"
> > user-emacs-directory))
> > (bootstrap-version 5))
> > (unless (file-exists-p bootstrap-file)
> > (with-current-buffer
> > (url-retrieve-synchronously
> > "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
> > 'silent 'inhibit-cookies)
> > (goto-char (point-max))
> > (eval-print-last-sexp)))
> > (load bootstrap-file nil 'nomessage))
> > (straight-use-package 'use-package)
> > (setq straight-use-package-by-default t)
> >
> > (use-package company
> > :demand t
> > :hook
> > (after-init . global-company-mode))
> > ```
> > But the `proxychains-ng-socks5` wrapper script relies on the normal HOME
> > variable setting. How to solve this dilemma?
> Well, you /could/ derive your version of HOME differently. Yes, let's go
> with that.
>
> Initially, HOME is derived from the 6th field in the user's
> /etc/passwd entry. You could
> - use whoami(1) to determine the username
> - use grep(1) and cut(1) (alternately, just awk(1) )to parse /etc/passwd
> and extract the home directory of the selected username
> - use that extracted home directory value to set your HOME variable

Do you mean this one?

$ grep ^"$(whoami)" /etc/passwd |cut -d ':' -f6
/home/werner

HZ

Re: Abnormal HOME variable modification requirements.

<sl998a$nas$1@tncsrv09.home.tnetconsulting.net>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4526&group=comp.unix.shell#4526

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!tncsrv06.tnetconsulting.net!tncsrv09.home.tnetconsulting.net!.POSTED.alpha.home.tnetconsulting.net!not-for-mail
From: gtay...@tnetconsulting.net (Grant Taylor)
Newsgroups: comp.unix.shell
Subject: Re: Abnormal HOME variable modification requirements.
Date: Tue, 26 Oct 2021 10:04:37 -0600
Organization: TNet Consulting
Message-ID: <sl998a$nas$1@tncsrv09.home.tnetconsulting.net>
References: <6e4cd80e-2513-4534-af7e-c9716c0b2e91n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 26 Oct 2021 16:09:46 -0000 (UTC)
Injection-Info: tncsrv09.home.tnetconsulting.net; posting-host="alpha.home.tnetconsulting.net:198.18.18.251";
logging-data="23900"; mail-complaints-to="newsmaster@tnetconsulting.net"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101
Thunderbird/78.13.0
In-Reply-To: <6e4cd80e-2513-4534-af7e-c9716c0b2e91n@googlegroups.com>
Content-Language: en-US
 by: Grant Taylor - Tue, 26 Oct 2021 16:04 UTC

On 10/26/21 6:47 AM, hongy...@gmail.com wrote:
> But the `proxychains-ng-socks5` wrapper script relies on the normal
> HOME variable setting. How to solve this dilemma?

Please elaborate on what the abnormal HOME variable contents are?

Are you artificially changing the HOME variable's contents at the start
of the script? It looks like it's commented out to me. (But I don't
speak LISP.)

I'm failing to fathom a case where the contents of HOME would not be normal.

--
Grant. . . .
unix || die

Re: Abnormal HOME variable modification requirements.

<sl9ckq$nc9$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4527&group=comp.unix.shell#4527

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: lew.pitc...@digitalfreehold.ca (Lew Pitcher)
Newsgroups: comp.unix.shell
Subject: Re: Abnormal HOME variable modification requirements.
Date: Tue, 26 Oct 2021 17:07:39 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 62
Message-ID: <sl9ckq$nc9$1@dont-email.me>
References: <6e4cd80e-2513-4534-af7e-c9716c0b2e91n@googlegroups.com>
<sl91cf$pr5$1@dont-email.me>
<175fb530-8edb-4216-9d67-c42b1fbd908fn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 26 Oct 2021 17:07:39 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="816c93de529df6f5f7d1a6545b4b51fa";
logging-data="23945"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19ybNP5VlDLV/vaqR0Lhc/HrLzeEhY8Kdo="
User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508
git://git.gnome.org/pan2)
Cancel-Lock: sha1:YyJC8uBA7sEYnvIElmztxzfDaHA=
 by: Lew Pitcher - Tue, 26 Oct 2021 17:07 UTC

On Tue, 26 Oct 2021 08:14:02 -0700, hongy...@gmail.com wrote:

> On Tuesday, October 26, 2021 at 9:55:32 PM UTC+8, Lew Pitcher wrote:
>> On Tue, 26 Oct 2021 05:47:48 -0700, hongy...@gmail.com wrote:
>>
>> > I've written the following Emacs package debug script which can be
>> > run by `$ bash /home/werner/.emacs.d/debug/.emacs.d/init.el`:
>> >
>> > ```emacs-lisp
>> > #!/usr/bin/env bash
>> > :;# $ realpath init.el
>> > :;# /home/werner/.emacs.d/debug/.emacs.d/init.el
>> > :; HOME=$(dirname $(dirname $(realpath -e $0))) proxychains-ng-socks5
>> > /usr/local/bin/emacs -- "$@"; exit
>> >
>> > ;;Bootstrap straight
>> > (defvar bootstrap-version)
>> > (let ((bootstrap-file
>> > (expand-file-name "straight/repos/straight.el/bootstrap.el"
>> > user-emacs-directory))
>> > (bootstrap-version 5))
>> > (unless (file-exists-p bootstrap-file)
>> > (with-current-buffer
>> > (url-retrieve-synchronously
>> > "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
>> > 'silent 'inhibit-cookies)
>> > (goto-char (point-max))
>> > (eval-print-last-sexp)))
>> > (load bootstrap-file nil 'nomessage))
>> > (straight-use-package 'use-package)
>> > (setq straight-use-package-by-default t)
>> >
>> > (use-package company
>> > :demand t
>> > :hook
>> > (after-init . global-company-mode))
>> > ```
>> > But the `proxychains-ng-socks5` wrapper script relies on the normal HOME
>> > variable setting. How to solve this dilemma?
>> Well, you /could/ derive your version of HOME differently. Yes, let's go
>> with that.
>>
>> Initially, HOME is derived from the 6th field in the user's
>> /etc/passwd entry. You could
>> - use whoami(1) to determine the username
>> - use grep(1) and cut(1) (alternately, just awk(1) )to parse /etc/passwd
>> and extract the home directory of the selected username
>> - use that extracted home directory value to set your HOME variable
>
> Do you mean this one?
>
> $ grep ^"$(whoami)" /etc/passwd |cut -d ':' -f6
> /home/werner

Sure. Or
$ awk -F : -v user=$(whoami) '$1 == user {print $6;}' /etc/passwd
/home/lpitcher

--
Lew Pitcher
"In Skills, We Trust"

Getting a home directory in shell script (Was: Abnormal HOME variable modification requirements.)

<sl9hu0$3qs9m$1@news.xmission.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4528&group=comp.unix.shell#4528

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!xmission!nnrp.xmission!.POSTED.shell.xmission.com!not-for-mail
From: gaze...@shell.xmission.com (Kenny McCormack)
Newsgroups: comp.unix.shell
Subject: Getting a home directory in shell script (Was: Abnormal HOME variable modification requirements.)
Date: Tue, 26 Oct 2021 18:37:52 -0000 (UTC)
Organization: The official candy of the new Millennium
Message-ID: <sl9hu0$3qs9m$1@news.xmission.com>
References: <6e4cd80e-2513-4534-af7e-c9716c0b2e91n@googlegroups.com> <sl91cf$pr5$1@dont-email.me> <175fb530-8edb-4216-9d67-c42b1fbd908fn@googlegroups.com> <sl9ckq$nc9$1@dont-email.me>
Injection-Date: Tue, 26 Oct 2021 18:37:52 -0000 (UTC)
Injection-Info: news.xmission.com; posting-host="shell.xmission.com:166.70.8.4";
logging-data="4026678"; mail-complaints-to="abuse@xmission.com"
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: gazelle@shell.xmission.com (Kenny McCormack)
 by: Kenny McCormack - Tue, 26 Oct 2021 18:37 UTC

In article <sl9ckq$nc9$1@dont-email.me>,
Lew Pitcher <lew.pitcher@digitalfreehold.ca> wrote:
>On Tue, 26 Oct 2021 08:14:02 -0700, hongy...@gmail.com wrote:
>
>> On Tuesday, October 26, 2021 at 9:55:32 PM UTC+8, Lew Pitcher wrote:
>>> On Tue, 26 Oct 2021 05:47:48 -0700, hongy...@gmail.com wrote:
>>>
>>> > I've written the following Emacs package debug script which can be
>>> > run by `$ bash /home/werner/.emacs.d/debug/.emacs.d/init.el`:
>>> >
>>> > ```emacs-lisp
>>> > #!/usr/bin/env bash
>>> > :;# $ realpath init.el
>>> > :;# /home/werner/.emacs.d/debug/.emacs.d/init.el
>>> > :; HOME=$(dirname $(dirname $(realpath -e $0))) proxychains-ng-socks5
>>> > /usr/local/bin/emacs -- "$@"; exit
>>> >
>>> > ;;Bootstrap straight
>>> > (defvar bootstrap-version)
>>> > (let ((bootstrap-file
>>> > (expand-file-name "straight/repos/straight.el/bootstrap.el"
>>> > user-emacs-directory))
>>> > (bootstrap-version 5))
>>> > (unless (file-exists-p bootstrap-file)
>>> > (with-current-buffer
>>> > (url-retrieve-synchronously
>>> > "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
>>> > 'silent 'inhibit-cookies)
>>> > (goto-char (point-max))
>>> > (eval-print-last-sexp)))
>>> > (load bootstrap-file nil 'nomessage))
>>> > (straight-use-package 'use-package)
>>> > (setq straight-use-package-by-default t)
>>> >
>>> > (use-package company
>>> > :demand t
>>> > :hook
>>> > (after-init . global-company-mode))
>>> > ```
>>> > But the `proxychains-ng-socks5` wrapper script relies on the normal HOME
>>> > variable setting. How to solve this dilemma?
>>> Well, you /could/ derive your version of HOME differently. Yes, let's go
>>> with that.
>>>
>>> Initially, HOME is derived from the 6th field in the user's
>>> /etc/passwd entry. You could
>>> - use whoami(1) to determine the username
>>> - use grep(1) and cut(1) (alternately, just awk(1) )to parse /etc/passwd
>>> and extract the home directory of the selected username
>>> - use that extracted home directory value to set your HOME variable
>>
>> Do you mean this one?
>>
>> $ grep ^"$(whoami)" /etc/passwd |cut -d ':' -f6
>> /home/werner
>
>Sure. Or
> $ awk -F : -v user=$(whoami) '$1 == user {print $6;}' /etc/passwd
> /home/lpitcher

Or just:

$ echo ~
and
$ echo ~lpitcher

--
People sleep peaceably in their beds at night only because rough
men stand ready to do violence on their behalf.

George Orwell

Re: Getting a home directory in shell script (Was: Abnormal HOME variable modification requirements.)

<eli$2110261502@qaz.wtf>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4529&group=comp.unix.shell#4529

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!panix!.POSTED.panix5.panix.com!qz!not-for-mail
From: *...@eli.users.panix.com (Eli the Bearded)
Newsgroups: comp.unix.shell
Subject: Re: Getting a home directory in shell script (Was: Abnormal HOME variable modification requirements.)
Date: Tue, 26 Oct 2021 19:10:57 -0000 (UTC)
Organization: Some absurd concept
Message-ID: <eli$2110261502@qaz.wtf>
References: <6e4cd80e-2513-4534-af7e-c9716c0b2e91n@googlegroups.com> <175fb530-8edb-4216-9d67-c42b1fbd908fn@googlegroups.com> <sl9ckq$nc9$1@dont-email.me> <sl9hu0$3qs9m$1@news.xmission.com>
Injection-Date: Tue, 26 Oct 2021 19:10:57 -0000 (UTC)
Injection-Info: reader1.panix.com; posting-host="panix5.panix.com:166.84.1.5";
logging-data="25520"; mail-complaints-to="abuse@panix.com"
User-Agent: Vectrex rn 2.1 (beta)
X-Liz: It's actually happened, the entire Internet is a massive game of Redcode
X-Motto: "Erosion of rights never seems to reverse itself." -- kenny@panix
X-US-Congress: Moronic Fucks.
X-Attribution: EtB
XFrom: is a real address
Encrypted: double rot-13
 by: Eli the Bearded - Tue, 26 Oct 2021 19:10 UTC

In comp.unix.shell, Kenny McCormack <gazelle@shell.xmission.com> wrote:
> Lew Pitcher <lew.pitcher@digitalfreehold.ca> wrote:
[ HOME=$(dirname $(dirname $(realpath -e $0))) proxychains-ng-socks5 ]
>> $ awk -F : -v user=$(whoami) '$1 == user {print $6;}' /etc/passwd
>> /home/lpitcher
> Or just:
>
> $ echo ~

I've just got to really wonder what's going on here. If I have set
HOME differently than the one in /etc/passwd, I probably have a good
reason for that and will not like having it reset.

I frequently use /var/tmp/$(whoami) as an alternative $HOME for testing
things, in particular testing how stuff works without all my dot files.
Or for say, testing how dot file installation from a home-config git
repo works.

I use other directories, too, but rarely. It's a handy way to have
multiple simultaneous news readers working with different .newsrc files,
for example.

Elijah
------
HOME=/var/tmp/elijah PS1=': subshell; ' $SHELL

Re: Abnormal HOME variable modification requirements.

<GK2dnWiQPbY-E-X8nZ2dnUU78XXNnZ2d@brightview.co.uk>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4530&group=comp.unix.shell#4530

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!4.us.feeder.erje.net!2.eu.feeder.erje.net!feeder.erje.net!border1.nntp.ams1.giganews.com!nntp.giganews.com!buffer1.nntp.ams1.giganews.com!nntp.brightview.co.uk!news.brightview.co.uk.POSTED!not-for-mail
NNTP-Posting-Date: Tue, 26 Oct 2021 18:26:27 -0500
From: inva...@invalid.invalid (Javier)
Subject: Re: Abnormal HOME variable modification requirements.
Newsgroups: comp.unix.shell
References: <6e4cd80e-2513-4534-af7e-c9716c0b2e91n@googlegroups.com>
Message-ID: <GK2dnWiQPbY-E-X8nZ2dnUU78XXNnZ2d@brightview.co.uk>
Date: Tue, 26 Oct 2021 18:26:27 -0500
Lines: 18
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-iJ0uVMNYFL6IYns6FN2KR/Yu5KmDizVj6mQWJeiZ9IBpgsM5DAsRp5zGSPleEv3nQ3qNUm9cR41lmDO!nDj4MblDZ/E6O6OM3ffl0mcJlITjsnLBQ7GEjdSCtFQCP613uDp5YC51tdGCslGPEyJFb3pWAtxq!BOGkSRoCalkVPrAN965+f6qnnvU=
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
X-Original-Bytes: 1675
 by: Javier - Tue, 26 Oct 2021 23:26 UTC

Some software uses /etc/passwd instead of the HOME variable.
It's a bug.

Possibly you can inspect 'proxychains-ng-socks5' if it's an script and
fix the bug yourself.

That bug was very common in the past. Fortunately nowadays most
software has fixed it. Ivan Shmakov commented about that in
comp.emacs a pair of years ago:

Ivan Shmakov <ivan@siamics.net> on comp.emacs
Message-ID: <8736wyx2p2.fsf_-_@violet.siamics.net>

Unfortunately, some software refers to passwd(5) data directly
instead, leaving no way for the user to override the home
directory location. In particular, this was the behavior (IIRC)
of programs based on older Glib versions. And I vaguely recall
that Emacs might have been affected as well.

Re: Abnormal HOME variable modification requirements.

<ee01adff-123e-4934-b3b8-0636be28a4c4n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4531&group=comp.unix.shell#4531

  copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:ad4:4144:: with SMTP id z4mr25721999qvp.22.1635295159798;
Tue, 26 Oct 2021 17:39:19 -0700 (PDT)
X-Received: by 2002:a05:620a:4725:: with SMTP id bs37mr1864950qkb.171.1635295159662;
Tue, 26 Oct 2021 17:39:19 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Tue, 26 Oct 2021 17:39:19 -0700 (PDT)
In-Reply-To: <GK2dnWiQPbY-E-X8nZ2dnUU78XXNnZ2d@brightview.co.uk>
Injection-Info: google-groups.googlegroups.com; posting-host=60.249.28.129; posting-account=kF0ZaAoAAACPbiK5gldhAyX5qTd3krV2
NNTP-Posting-Host: 60.249.28.129
References: <6e4cd80e-2513-4534-af7e-c9716c0b2e91n@googlegroups.com> <GK2dnWiQPbY-E-X8nZ2dnUU78XXNnZ2d@brightview.co.uk>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <ee01adff-123e-4934-b3b8-0636be28a4c4n@googlegroups.com>
Subject: Re: Abnormal HOME variable modification requirements.
From: hongyi.z...@gmail.com (hongy...@gmail.com)
Injection-Date: Wed, 27 Oct 2021 00:39:19 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 20
 by: hongy...@gmail.com - Wed, 27 Oct 2021 00:39 UTC

On Wednesday, October 27, 2021 at 7:26:34 AM UTC+8, Javier wrote:
> Some software uses /etc/passwd instead of the HOME variable.
> It's a bug.
>
> Possibly you can inspect 'proxychains-ng-socks5' if it's an script and
> fix the bug yourself.
>
> That bug was very common in the past. Fortunately nowadays most
> software has fixed it. Ivan Shmakov commented about that in
> comp.emacs a pair of years ago:
>
> Ivan Shmakov <iv...@siamics.net> on comp.emacs
> Message-ID: <8736wyx2...@violet.siamics.net>
>
> Unfortunately, some software refers to passwd(5) data directly
> instead, leaving no way for the user to override the home
> directory location. In particular, this was the behavior (IIRC)
> of programs based on older Glib versions. And I vaguely recall
> that Emacs might have been affected as well.

Thank you for much for your explanation. This is just the case of my dilemma.

Re: Getting a home directory in shell script (Was: Abnormal HOME variable modification requirements.)

<4df22c57-4b7a-4427-9155-a41aa4ede1cen@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4532&group=comp.unix.shell#4532

  copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:ac8:5bcd:: with SMTP id b13mr28773770qtb.297.1635295511768;
Tue, 26 Oct 2021 17:45:11 -0700 (PDT)
X-Received: by 2002:a37:2cc4:: with SMTP id s187mr21965434qkh.407.1635295511638;
Tue, 26 Oct 2021 17:45:11 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Tue, 26 Oct 2021 17:45:11 -0700 (PDT)
In-Reply-To: <sl9hu0$3qs9m$1@news.xmission.com>
Injection-Info: google-groups.googlegroups.com; posting-host=3.35.169.74; posting-account=kF0ZaAoAAACPbiK5gldhAyX5qTd3krV2
NNTP-Posting-Host: 3.35.169.74
References: <6e4cd80e-2513-4534-af7e-c9716c0b2e91n@googlegroups.com>
<sl91cf$pr5$1@dont-email.me> <175fb530-8edb-4216-9d67-c42b1fbd908fn@googlegroups.com>
<sl9ckq$nc9$1@dont-email.me> <sl9hu0$3qs9m$1@news.xmission.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <4df22c57-4b7a-4427-9155-a41aa4ede1cen@googlegroups.com>
Subject: Re: Getting a home directory in shell script (Was: Abnormal HOME
variable modification requirements.)
From: hongyi.z...@gmail.com (hongy...@gmail.com)
Injection-Date: Wed, 27 Oct 2021 00:45:11 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 72
 by: hongy...@gmail.com - Wed, 27 Oct 2021 00:45 UTC

On Wednesday, October 27, 2021 at 2:37:57 AM UTC+8, Kenny McCormack wrote:
> In article <sl9ckq$nc9$1...@dont-email.me>,
> Lew Pitcher <lew.p...@digitalfreehold.ca> wrote:
> >On Tue, 26 Oct 2021 08:14:02 -0700, hongy...@gmail.com wrote:
> >
> >> On Tuesday, October 26, 2021 at 9:55:32 PM UTC+8, Lew Pitcher wrote:
> >>> On Tue, 26 Oct 2021 05:47:48 -0700, hongy...@gmail.com wrote:
> >>>
> >>> > I've written the following Emacs package debug script which can be
> >>> > run by `$ bash /home/werner/.emacs.d/debug/.emacs.d/init.el`:
> >>> >
> >>> > ```emacs-lisp
> >>> > #!/usr/bin/env bash
> >>> > :;# $ realpath init.el
> >>> > :;# /home/werner/.emacs.d/debug/.emacs.d/init.el
> >>> > :; HOME=$(dirname $(dirname $(realpath -e $0))) proxychains-ng-socks5
> >>> > /usr/local/bin/emacs -- "$@"; exit
> >>> >
> >>> > ;;Bootstrap straight
> >>> > (defvar bootstrap-version)
> >>> > (let ((bootstrap-file
> >>> > (expand-file-name "straight/repos/straight.el/bootstrap.el"
> >>> > user-emacs-directory))
> >>> > (bootstrap-version 5))
> >>> > (unless (file-exists-p bootstrap-file)
> >>> > (with-current-buffer
> >>> > (url-retrieve-synchronously
> >>> > "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
> >>> > 'silent 'inhibit-cookies)
> >>> > (goto-char (point-max))
> >>> > (eval-print-last-sexp)))
> >>> > (load bootstrap-file nil 'nomessage))
> >>> > (straight-use-package 'use-package)
> >>> > (setq straight-use-package-by-default t)
> >>> >
> >>> > (use-package company
> >>> > :demand t
> >>> > :hook
> >>> > (after-init . global-company-mode))
> >>> > ```
> >>> > But the `proxychains-ng-socks5` wrapper script relies on the normal HOME
> >>> > variable setting. How to solve this dilemma?
> >>> Well, you /could/ derive your version of HOME differently. Yes, let's go
> >>> with that.
> >>>
> >>> Initially, HOME is derived from the 6th field in the user's
> >>> /etc/passwd entry. You could
> >>> - use whoami(1) to determine the username
> >>> - use grep(1) and cut(1) (alternately, just awk(1) )to parse /etc/passwd
> >>> and extract the home directory of the selected username
> >>> - use that extracted home directory value to set your HOME variable
> >>
> >> Do you mean this one?
> >>
> >> $ grep ^"$(whoami)" /etc/passwd |cut -d ':' -f6
> >> /home/werner
> >
> >Sure. Or
> > $ awk -F : -v user=$(whoami) '$1 == user {print $6;}' /etc/passwd
> > /home/lpitcher
> Or just:
>
> $ echo ~
> and
> $ echo ~lpitcher

This doesn't work for the Emacs case. If the HOME has been changed from within the session where Emacs is started, it won't use the new HOME as ~.
> --
> People sleep peaceably in their beds at night only because rough
> men stand ready to do violence on their behalf.
>
> George Orwell

Re: Getting a home directory in shell script (Was: Abnormal HOME variable modification requirements.)

<slbnsh$1dj$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4533&group=comp.unix.shell#4533

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: lew.pitc...@digitalfreehold.ca (Lew Pitcher)
Newsgroups: comp.unix.shell
Subject: Re: Getting a home directory in shell script (Was: Abnormal HOME
variable modification requirements.)
Date: Wed, 27 Oct 2021 14:31:45 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 95
Message-ID: <slbnsh$1dj$1@dont-email.me>
References: <6e4cd80e-2513-4534-af7e-c9716c0b2e91n@googlegroups.com>
<sl91cf$pr5$1@dont-email.me>
<175fb530-8edb-4216-9d67-c42b1fbd908fn@googlegroups.com>
<sl9ckq$nc9$1@dont-email.me> <sl9hu0$3qs9m$1@news.xmission.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 27 Oct 2021 14:31:45 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="4a817e4f3d3a686475df80cacd32acbd";
logging-data="1459"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19Ya7vi5Ma2AaaYJPhPyTwpWAdZHvKeLAE="
User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508
git://git.gnome.org/pan2)
Cancel-Lock: sha1:1w7EZS7RUN0/AnQu0/AKU2pel/U=
 by: Lew Pitcher - Wed, 27 Oct 2021 14:31 UTC

On Tue, 26 Oct 2021 18:37:52 +0000, Kenny McCormack wrote:

> In article <sl9ckq$nc9$1@dont-email.me>,
> Lew Pitcher <lew.pitcher@digitalfreehold.ca> wrote:
>>On Tue, 26 Oct 2021 08:14:02 -0700, hongy...@gmail.com wrote:
>>
>>> On Tuesday, October 26, 2021 at 9:55:32 PM UTC+8, Lew Pitcher wrote:
>>>> On Tue, 26 Oct 2021 05:47:48 -0700, hongy...@gmail.com wrote:
>>>>
>>>> > I've written the following Emacs package debug script which can be
>>>> > run by `$ bash /home/werner/.emacs.d/debug/.emacs.d/init.el`:
>>>> >
>>>> > ```emacs-lisp
>>>> > #!/usr/bin/env bash
>>>> > :;# $ realpath init.el
>>>> > :;# /home/werner/.emacs.d/debug/.emacs.d/init.el
>>>> > :; HOME=$(dirname $(dirname $(realpath -e $0))) proxychains-ng-socks5
>>>> > /usr/local/bin/emacs -- "$@"; exit
>>>> >
>>>> > ;;Bootstrap straight
>>>> > (defvar bootstrap-version)
>>>> > (let ((bootstrap-file
>>>> > (expand-file-name "straight/repos/straight.el/bootstrap.el"
>>>> > user-emacs-directory))
>>>> > (bootstrap-version 5))
>>>> > (unless (file-exists-p bootstrap-file)
>>>> > (with-current-buffer
>>>> > (url-retrieve-synchronously
>>>> > "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
>>>> > 'silent 'inhibit-cookies)
>>>> > (goto-char (point-max))
>>>> > (eval-print-last-sexp)))
>>>> > (load bootstrap-file nil 'nomessage))
>>>> > (straight-use-package 'use-package)
>>>> > (setq straight-use-package-by-default t)
>>>> >
>>>> > (use-package company
>>>> > :demand t
>>>> > :hook
>>>> > (after-init . global-company-mode))
>>>> > ```
>>>> > But the `proxychains-ng-socks5` wrapper script relies on the normal HOME
>>>> > variable setting. How to solve this dilemma?
>>>> Well, you /could/ derive your version of HOME differently. Yes, let's go
>>>> with that.
>>>>
>>>> Initially, HOME is derived from the 6th field in the user's
>>>> /etc/passwd entry. You could
>>>> - use whoami(1) to determine the username
>>>> - use grep(1) and cut(1) (alternately, just awk(1) )to parse /etc/passwd
>>>> and extract the home directory of the selected username
>>>> - use that extracted home directory value to set your HOME variable
>>>
>>> Do you mean this one?
>>>
>>> $ grep ^"$(whoami)" /etc/passwd |cut -d ':' -f6
>>> /home/werner
>>
>>Sure. Or
>> $ awk -F : -v user=$(whoami) '$1 == user {print $6;}' /etc/passwd
>> /home/lpitcher
>
> Or just:
>
> $ echo ~
> and
> $ echo ~lpitcher

If $HOME is not reliably set, then ~ is unlikely to be either.
Witness:

10:27 $ echo $HOME
/home/lpitcher
10:27 $ echo ~
/home/lpitcher

Both $HOME and ~ point at my home directory

But now, I change $HOME to point somewhere else
10:27 $ HOME=/var/some/directory
10:28 $ echo $HOME
/var/some/directory

And, lo and behold, ~ changes as well
10:28 $ echo ~
/var/some/directory

So, if the OP can't depend on $HOME to point to the proper
directory (hence, his asking how to derive the home directory)
then he can't depend on ~ either.

HTH
--
Lew Pitcher
"In Skills, We Trust"

Re: Getting a home directory in shell script (Was: Abnormal HOME variable modification requirements.)

<slc19m$f62$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4534&group=comp.unix.shell#4534

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: lew.pitc...@digitalfreehold.ca (Lew Pitcher)
Newsgroups: comp.unix.shell
Subject: Re: Getting a home directory in shell script (Was: Abnormal HOME
variable modification requirements.)
Date: Wed, 27 Oct 2021 17:12:22 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 106
Message-ID: <slc19m$f62$1@dont-email.me>
References: <6e4cd80e-2513-4534-af7e-c9716c0b2e91n@googlegroups.com>
<sl91cf$pr5$1@dont-email.me>
<175fb530-8edb-4216-9d67-c42b1fbd908fn@googlegroups.com>
<sl9ckq$nc9$1@dont-email.me> <sl9hu0$3qs9m$1@news.xmission.com>
<slbnsh$1dj$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 27 Oct 2021 17:12:22 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="4a817e4f3d3a686475df80cacd32acbd";
logging-data="15554"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+eVHcIpg07kITz7CqlA7tzpdczWKJQf2U="
User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508
git://git.gnome.org/pan2)
Cancel-Lock: sha1:55AVT8KWeRcmQx6NHs60aXKG01Q=
 by: Lew Pitcher - Wed, 27 Oct 2021 17:12 UTC

On Wed, 27 Oct 2021 14:31:45 +0000, Lew Pitcher wrote:

> On Tue, 26 Oct 2021 18:37:52 +0000, Kenny McCormack wrote:
>
>> In article <sl9ckq$nc9$1@dont-email.me>,
>> Lew Pitcher <lew.pitcher@digitalfreehold.ca> wrote:
>>>On Tue, 26 Oct 2021 08:14:02 -0700, hongy...@gmail.com wrote:
>>>
>>>> On Tuesday, October 26, 2021 at 9:55:32 PM UTC+8, Lew Pitcher wrote:
>>>>> On Tue, 26 Oct 2021 05:47:48 -0700, hongy...@gmail.com wrote:
>>>>>
>>>>> > I've written the following Emacs package debug script which can be
>>>>> > run by `$ bash /home/werner/.emacs.d/debug/.emacs.d/init.el`:
>>>>> >
>>>>> > ```emacs-lisp
>>>>> > #!/usr/bin/env bash
>>>>> > :;# $ realpath init.el
>>>>> > :;# /home/werner/.emacs.d/debug/.emacs.d/init.el
>>>>> > :; HOME=$(dirname $(dirname $(realpath -e $0))) proxychains-ng-socks5
>>>>> > /usr/local/bin/emacs -- "$@"; exit
>>>>> >
>>>>> > ;;Bootstrap straight
>>>>> > (defvar bootstrap-version)
>>>>> > (let ((bootstrap-file
>>>>> > (expand-file-name "straight/repos/straight.el/bootstrap.el"
>>>>> > user-emacs-directory))
>>>>> > (bootstrap-version 5))
>>>>> > (unless (file-exists-p bootstrap-file)
>>>>> > (with-current-buffer
>>>>> > (url-retrieve-synchronously
>>>>> > "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
>>>>> > 'silent 'inhibit-cookies)
>>>>> > (goto-char (point-max))
>>>>> > (eval-print-last-sexp)))
>>>>> > (load bootstrap-file nil 'nomessage))
>>>>> > (straight-use-package 'use-package)
>>>>> > (setq straight-use-package-by-default t)
>>>>> >
>>>>> > (use-package company
>>>>> > :demand t
>>>>> > :hook
>>>>> > (after-init . global-company-mode))
>>>>> > ```
>>>>> > But the `proxychains-ng-socks5` wrapper script relies on the normal HOME
>>>>> > variable setting. How to solve this dilemma?
>>>>> Well, you /could/ derive your version of HOME differently. Yes, let's go
>>>>> with that.
>>>>>
>>>>> Initially, HOME is derived from the 6th field in the user's
>>>>> /etc/passwd entry. You could
>>>>> - use whoami(1) to determine the username
>>>>> - use grep(1) and cut(1) (alternately, just awk(1) )to parse /etc/passwd
>>>>> and extract the home directory of the selected username
>>>>> - use that extracted home directory value to set your HOME variable
>>>>
>>>> Do you mean this one?
>>>>
>>>> $ grep ^"$(whoami)" /etc/passwd |cut -d ':' -f6
>>>> /home/werner
>>>
>>>Sure. Or
>>> $ awk -F : -v user=$(whoami) '$1 == user {print $6;}' /etc/passwd
>>> /home/lpitcher
>>
>> Or just:
>>
>> $ echo ~
>> and
>> $ echo ~lpitcher
>
> If $HOME is not reliably set, then ~ is unlikely to be either.
> Witness:
>
> 10:27 $ echo $HOME
> /home/lpitcher
> 10:27 $ echo ~
> /home/lpitcher
>
> Both $HOME and ~ point at my home directory
>
> But now, I change $HOME to point somewhere else
> 10:27 $ HOME=/var/some/directory
> 10:28 $ echo $HOME
> /var/some/directory
>
> And, lo and behold, ~ changes as well
> 10:28 $ echo ~
> /var/some/directory
>
> So, if the OP can't depend on $HOME to point to the proper
> directory (hence, his asking how to derive the home directory)
> then he can't depend on ~ either.
>
> HTH

FWIW, from bash(1):
Shell Variables
The following variables are set by the shell:
...
HOME The home directory of the current user; the default argument for
the cd builtin command. The value of this variable is also used
when performing tilde expansion.

--
Lew Pitcher
"In Skills, We Trust"

Re: Getting a home directory in shell script

<87ee861j39.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4535&group=comp.unix.shell#4535

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.unix.shell
Subject: Re: Getting a home directory in shell script
Date: Wed, 27 Oct 2021 10:19:22 -0700
Organization: None to speak of
Lines: 55
Message-ID: <87ee861j39.fsf@nosuchdomain.example.com>
References: <6e4cd80e-2513-4534-af7e-c9716c0b2e91n@googlegroups.com>
<sl91cf$pr5$1@dont-email.me>
<175fb530-8edb-4216-9d67-c42b1fbd908fn@googlegroups.com>
<sl9ckq$nc9$1@dont-email.me> <sl9hu0$3qs9m$1@news.xmission.com>
<slbnsh$1dj$1@dont-email.me> <slc19m$f62$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="5ceb257dd6384d139e9fcd3999f25351";
logging-data="21278"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18xNbKwDAEkhSqC35nLkXxd"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:o72XO+2e02Zex9OHcbVYZhZSWNE=
sha1:BqKM5pDfi7e+Vo7LzLqgPS68K0Y=
 by: Keith Thompson - Wed, 27 Oct 2021 17:19 UTC

Lew Pitcher <lew.pitcher@digitalfreehold.ca> writes:
> On Wed, 27 Oct 2021 14:31:45 +0000, Lew Pitcher wrote:
[...]
>> If $HOME is not reliably set, then ~ is unlikely to be either.
>> Witness:
>>
>> 10:27 $ echo $HOME
>> /home/lpitcher
>> 10:27 $ echo ~
>> /home/lpitcher
>>
>> Both $HOME and ~ point at my home directory
>>
>> But now, I change $HOME to point somewhere else
>> 10:27 $ HOME=/var/some/directory
>> 10:28 $ echo $HOME
>> /var/some/directory
>>
>> And, lo and behold, ~ changes as well
>> 10:28 $ echo ~
>> /var/some/directory
>>
>> So, if the OP can't depend on $HOME to point to the proper
>> directory (hence, his asking how to derive the home directory)
>> then he can't depend on ~ either.
>>
>> HTH
>
> FWIW, from bash(1):
> Shell Variables
> The following variables are set by the shell:
> ...
> HOME The home directory of the current user; the default argument for
> the cd builtin command. The value of this variable is also used
> when performing tilde expansion.

On the other hand, ~username, as opposed to just ~, does not depend on
$HOME. It does a lookup in /etc/passwd or whatever the system's
equivalent is.

$ echo $HOME ~ ~kst
/home/kst /home/kst /home/kst
$ HOME=/tmp
$ echo $HOME ~ ~kst
/tmp /tmp /home/kst
$ eval echo ~$USER
/home/kst
$ eval echo ~$(whoami)
/home/kst
$

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips
void Void(void) { Void(); } /* The recursive call of the void */

Re: Getting a home directory in shell script

<slc4n7$f62$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4536&group=comp.unix.shell#4536

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: lew.pitc...@digitalfreehold.ca (Lew Pitcher)
Newsgroups: comp.unix.shell
Subject: Re: Getting a home directory in shell script
Date: Wed, 27 Oct 2021 18:10:47 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 60
Message-ID: <slc4n7$f62$2@dont-email.me>
References: <6e4cd80e-2513-4534-af7e-c9716c0b2e91n@googlegroups.com>
<sl91cf$pr5$1@dont-email.me>
<175fb530-8edb-4216-9d67-c42b1fbd908fn@googlegroups.com>
<sl9ckq$nc9$1@dont-email.me> <sl9hu0$3qs9m$1@news.xmission.com>
<slbnsh$1dj$1@dont-email.me> <slc19m$f62$1@dont-email.me>
<87ee861j39.fsf@nosuchdomain.example.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 27 Oct 2021 18:10:47 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="4a817e4f3d3a686475df80cacd32acbd";
logging-data="15554"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX183U1oxX8Y6g2AcUbp5bV2tmZ4qVki8/w0="
User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508
git://git.gnome.org/pan2)
Cancel-Lock: sha1:83+HTid4EWbEqaS8cV4i08lHDqE=
 by: Lew Pitcher - Wed, 27 Oct 2021 18:10 UTC

On Wed, 27 Oct 2021 10:19:22 -0700, Keith Thompson wrote:

> Lew Pitcher <lew.pitcher@digitalfreehold.ca> writes:
>> On Wed, 27 Oct 2021 14:31:45 +0000, Lew Pitcher wrote:
> [...]
>>> If $HOME is not reliably set, then ~ is unlikely to be either.
>>> Witness:
>>>
>>> 10:27 $ echo $HOME
>>> /home/lpitcher
>>> 10:27 $ echo ~
>>> /home/lpitcher
>>>
>>> Both $HOME and ~ point at my home directory
>>>
>>> But now, I change $HOME to point somewhere else
>>> 10:27 $ HOME=/var/some/directory
>>> 10:28 $ echo $HOME
>>> /var/some/directory
>>>
>>> And, lo and behold, ~ changes as well
>>> 10:28 $ echo ~
>>> /var/some/directory
>>>
>>> So, if the OP can't depend on $HOME to point to the proper
>>> directory (hence, his asking how to derive the home directory)
>>> then he can't depend on ~ either.
>>>
>>> HTH
>>
>> FWIW, from bash(1):
>> Shell Variables
>> The following variables are set by the shell:
>> ...
>> HOME The home directory of the current user; the default argument for
>> the cd builtin command. The value of this variable is also used
>> when performing tilde expansion.
>
> On the other hand, ~username, as opposed to just ~, does not depend on
> $HOME. It does a lookup in /etc/passwd or whatever the system's
> equivalent is.
>
> $ echo $HOME ~ ~kst
> /home/kst /home/kst /home/kst
> $ HOME=/tmp
> $ echo $HOME ~ ~kst
> /tmp /tmp /home/kst
> $ eval echo ~$USER
> /home/kst
> $ eval echo ~$(whoami)
> /home/kst
> $

Thanks, Keith

I'm glad to have learned something new today.

--
Lew Pitcher
"In Skills, We Trust"

Re: Getting a home directory in shell script

<01b736e1-5e2d-44ba-8788-9dc69025bf40n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4538&group=comp.unix.shell#4538

  copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:a37:9a90:: with SMTP id c138mr2290967qke.442.1635408438103;
Thu, 28 Oct 2021 01:07:18 -0700 (PDT)
X-Received: by 2002:a05:622a:1102:: with SMTP id e2mr2892332qty.171.1635408437971;
Thu, 28 Oct 2021 01:07:17 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.mixmin.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Thu, 28 Oct 2021 01:07:17 -0700 (PDT)
In-Reply-To: <slc4n7$f62$2@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=143.198.81.107; posting-account=kF0ZaAoAAACPbiK5gldhAyX5qTd3krV2
NNTP-Posting-Host: 143.198.81.107
References: <6e4cd80e-2513-4534-af7e-c9716c0b2e91n@googlegroups.com>
<sl91cf$pr5$1@dont-email.me> <175fb530-8edb-4216-9d67-c42b1fbd908fn@googlegroups.com>
<sl9ckq$nc9$1@dont-email.me> <sl9hu0$3qs9m$1@news.xmission.com>
<slbnsh$1dj$1@dont-email.me> <slc19m$f62$1@dont-email.me> <87ee861j39.fsf@nosuchdomain.example.com>
<slc4n7$f62$2@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <01b736e1-5e2d-44ba-8788-9dc69025bf40n@googlegroups.com>
Subject: Re: Getting a home directory in shell script
From: hongyi.z...@gmail.com (hongy...@gmail.com)
Injection-Date: Thu, 28 Oct 2021 08:07:18 +0000
Content-Type: text/plain; charset="UTF-8"
 by: hongy...@gmail.com - Thu, 28 Oct 2021 08:07 UTC

On Thursday, October 28, 2021 at 2:10:52 AM UTC+8, Lew Pitcher wrote:
> On Wed, 27 Oct 2021 10:19:22 -0700, Keith Thompson wrote:
>
> > Lew Pitcher <lew.p...@digitalfreehold.ca> writes:
> >> On Wed, 27 Oct 2021 14:31:45 +0000, Lew Pitcher wrote:
> > [...]
> >>> If $HOME is not reliably set, then ~ is unlikely to be either.
> >>> Witness:
> >>>
> >>> 10:27 $ echo $HOME
> >>> /home/lpitcher
> >>> 10:27 $ echo ~
> >>> /home/lpitcher
> >>>
> >>> Both $HOME and ~ point at my home directory
> >>>
> >>> But now, I change $HOME to point somewhere else
> >>> 10:27 $ HOME=/var/some/directory
> >>> 10:28 $ echo $HOME
> >>> /var/some/directory
> >>>
> >>> And, lo and behold, ~ changes as well
> >>> 10:28 $ echo ~
> >>> /var/some/directory
> >>>
> >>> So, if the OP can't depend on $HOME to point to the proper
> >>> directory (hence, his asking how to derive the home directory)
> >>> then he can't depend on ~ either.
> >>>
> >>> HTH
> >>
> >> FWIW, from bash(1):
> >> Shell Variables
> >> The following variables are set by the shell:
> >> ...
> >> HOME The home directory of the current user; the default argument for
> >> the cd builtin command. The value of this variable is also used
> >> when performing tilde expansion.
> >
> > On the other hand, ~username, as opposed to just ~, does not depend on
> > $HOME. It does a lookup in /etc/passwd or whatever the system's
> > equivalent is.
> >
> > $ echo $HOME ~ ~kst
> > /home/kst /home/kst /home/kst
> > $ HOME=/tmp
> > $ echo $HOME ~ ~kst
> > /tmp /tmp /home/kst
> > $ eval echo ~$USER
> > /home/kst
> > $ eval echo ~$(whoami)
> > /home/kst
> > $
> Thanks, Keith
>
> I'm glad to have learned something new today.

Me too; so am I; So do I.

Re: Getting a home directory in shell script

<2e48b399-4be1-4cc4-9609-82ef6cd17cf7n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=4539&group=comp.unix.shell#4539

  copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:a05:6214:2307:: with SMTP id gc7mr2911017qvb.34.1635409419390;
Thu, 28 Oct 2021 01:23:39 -0700 (PDT)
X-Received: by 2002:ac8:7193:: with SMTP id w19mr2970006qto.311.1635409419269;
Thu, 28 Oct 2021 01:23:39 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Thu, 28 Oct 2021 01:23:39 -0700 (PDT)
In-Reply-To: <87ee861j39.fsf@nosuchdomain.example.com>
Injection-Info: google-groups.googlegroups.com; posting-host=128.199.66.218; posting-account=kF0ZaAoAAACPbiK5gldhAyX5qTd3krV2
NNTP-Posting-Host: 128.199.66.218
References: <6e4cd80e-2513-4534-af7e-c9716c0b2e91n@googlegroups.com>
<sl91cf$pr5$1@dont-email.me> <175fb530-8edb-4216-9d67-c42b1fbd908fn@googlegroups.com>
<sl9ckq$nc9$1@dont-email.me> <sl9hu0$3qs9m$1@news.xmission.com>
<slbnsh$1dj$1@dont-email.me> <slc19m$f62$1@dont-email.me> <87ee861j39.fsf@nosuchdomain.example.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <2e48b399-4be1-4cc4-9609-82ef6cd17cf7n@googlegroups.com>
Subject: Re: Getting a home directory in shell script
From: hongyi.z...@gmail.com (hongy...@gmail.com)
Injection-Date: Thu, 28 Oct 2021 08:23:39 +0000
Content-Type: text/plain; charset="UTF-8"
 by: hongy...@gmail.com - Thu, 28 Oct 2021 08:23 UTC

On Thursday, October 28, 2021 at 1:19:27 AM UTC+8, Keith Thompson wrote:
> Lew Pitcher <lew.p...@digitalfreehold.ca> writes:
> > On Wed, 27 Oct 2021 14:31:45 +0000, Lew Pitcher wrote:
> [...]
> >> If $HOME is not reliably set, then ~ is unlikely to be either.
> >> Witness:
> >>
> >> 10:27 $ echo $HOME
> >> /home/lpitcher
> >> 10:27 $ echo ~
> >> /home/lpitcher
> >>
> >> Both $HOME and ~ point at my home directory
> >>
> >> But now, I change $HOME to point somewhere else
> >> 10:27 $ HOME=/var/some/directory
> >> 10:28 $ echo $HOME
> >> /var/some/directory
> >>
> >> And, lo and behold, ~ changes as well
> >> 10:28 $ echo ~
> >> /var/some/directory
> >>
> >> So, if the OP can't depend on $HOME to point to the proper
> >> directory (hence, his asking how to derive the home directory)
> >> then he can't depend on ~ either.
> >>
> >> HTH
> >
> > FWIW, from bash(1):
> > Shell Variables
> > The following variables are set by the shell:
> > ...
> > HOME The home directory of the current user; the default argument for
> > the cd builtin command. The value of this variable is also used
> > when performing tilde expansion.
> On the other hand, ~username, as opposed to just ~, does not depend on
> $HOME. It does a lookup in /etc/passwd or whatever the system's
> equivalent is.
>
> $ echo $HOME ~ ~kst
> /home/kst /home/kst /home/kst
> $ HOME=/tmp
> $ echo $HOME ~ ~kst
> /tmp /tmp /home/kst
> $ eval echo ~$USER
> /home/kst

> $ eval echo ~$(whoami)
> /home/kst
> $

Some supplement

werner@X10DAi-00:~$ echo $(eval echo ~$USER)
/home/werner
werner@X10DAi-00:~$ echo $(eval echo ~$USERNAME)
/home/werner
werner@X10DAi-00:~$ echo $(eval echo ~$(whoami))
/home/werner

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor