Re: How do you get different $PS1 for /bin/sh and /bin/ksh?

2020-09-19 Thread Tom H
On Fri, Sep 18, 2020 at 10:26 AM Ottavio Caruso
 wrote:
> On 18/09/2020 09:01, Tom H wrote:
>> On Thu, Sep 17, 2020 at 3:16 PM Ottavio Caruso
>>  wrote:
>>> On 17/09/2020 10:40, Tom H wrote:


 You've said that you're now sourcing "$HOME/.kshrc" if
 "SKSH_VERSION" exists.

 You could add the sourcing of "$HOME/.shrc" if "$SH_VERSION"
 exists.

 Or you could export ENV and use a case-esac of this kind:

 case "$0" in
 *ksh)
 ...
 PS1='\u@\h:\w\$ '
 ;;
 *sh)
 ...
 PS1='${USER}@${HOST}:${PWD}\$ '
 ;;
 esac
>>>
>>> This solves the problem. Thanks.
>>
>> You're welcome.
>>
>> But, out of curiosity, which option did you choose? TIA
>
> Ah sorry, I used the second option.
>
> I have this in .profile:
>
> export ENV="$HOME/.kshrc"
>
> and this in .kshrc:
>
> case "$0" in
> *ksh)
> PS1='\u@\h:\w\$ '
> ;;
> *sh)
> PS1='${USER}@${HOST}:${PWD}\$ '
> ;;
> esac

OK. Thanks.


> On my NetBSD VM, sh and ksh are two different executables. ENV points
> to ~/.shrc which then sources ./.kshrc if KSH_VERSION = true
>
> I have thought of replicating the same configuration over to OpenBSD
> but I might be looking for trouble.

I use the same dotfiles on OpenBSD and NetBSD (I therefore don't use
OpenBSD's ksh backslash-escaped variables).


> On a side note, there's no mention of startup files in sh(1) and I
> wonder why.

Because POSIX sh doesn't define startup files, only "ENV".

4.2BSD sh, on the other hand, read "$HOME/.profile" (only) in login
mode, but didn't read "ENV" in interactive mode.



Re: How do you get different $PS1 for /bin/sh and /bin/ksh?

2020-09-18 Thread Ingo Schwarze
Hi Ottavio,

Ottavio Caruso wrote on Fri, Sep 18, 2020 at 09:22:11AM +0100:

> On a side note, there's no mention of startup files in sh(1)
> and I wonder why.

>From sh(1), second paragraph:

  This manual page describes only the parts relevant to a POSIX
  compliant sh.  If portability is a concern, use only those
  features described in this page.

POSIX does not require that the shell handles any startup files,
neither any with "profile" in the name, nor any with "rc" in the name,
nor any with "login" in the name, see

  https://pubs.opengroup.org/onlinepubs/9699919799/utilities/sh.html

I does require ENV though, and consequently, sh(1) mentions that.

Yours,
  Ingo



Re: How do you get different $PS1 for /bin/sh and /bin/ksh?

2020-09-18 Thread Ottavio Caruso

On 18/09/2020 09:01, Tom H wrote:

On Thu, Sep 17, 2020 at 3:16 PM Ottavio Caruso
 wrote:

On 17/09/2020 10:40, Tom H wrote:


You've said that you're now sourcing "$HOME/.kshrc" if
"SKSH_VERSION" exists.

You could add the sourcing of "$HOME/.shrc" if "$SH_VERSION" exists.

Or you could export ENV and use a case-esac of this kind:

case "$0" in
*ksh)
...
PS1='\u@\h:\w\$ '
;;
*sh)
...
PS1='${USER}@${HOST}:${PWD}\$ '
;;
esac


This solves the problem. Thanks.


You're welcome.

But, out of curiosity, which option did you choose? TIA


Ah sorry,  I used the second option. I have this in .profile:

export ENV="$HOME/.kshrc"


and this in .kshrc:


case "$0" in
*ksh)
PS1='\u@\h:\w\$ '
;;
*sh)
PS1='${USER}@${HOST}:${PWD}\$ '
;;
esac


On my NetBSD VM, sh and ksh are two different executables. ENV points to 
~/.shrc which then sources ./.kshrc if KSH_VERSION = true


I have though of replicating the same configuration over to OpenBSD but 
I might be looking for trouble.


On a side note, there's no mention of startup files in sh(1) and I 
wonder why.



--
Ottavio Caruso





Re: How do you get different $PS1 for /bin/sh and /bin/ksh?

2020-09-18 Thread Tom H
On Thu, Sep 17, 2020 at 3:16 PM Ottavio Caruso
 wrote:
> On 17/09/2020 10:40, Tom H wrote:
>>
>> You've said that you're now sourcing "$HOME/.kshrc" if
>>"SKSH_VERSION" exists.
>>
>> You could add the sourcing of "$HOME/.shrc" if "$SH_VERSION" exists.
>>
>> Or you could export ENV and use a case-esac of this kind:
>>
>> case "$0" in
>> *ksh)
>> ...
>> PS1='\u@\h:\w\$ '
>> ;;
>> *sh)
>> ...
>> PS1='${USER}@${HOST}:${PWD}\$ '
>> ;;
>> esac
>
> This solves the problem. Thanks.

You're welcome.

But, out of curiosity, which option did you choose? TIA



Re: How do you get different $PS1 for /bin/sh and /bin/ksh?

2020-09-17 Thread Ottavio Caruso

On 17/09/2020 10:40, Tom H wrote:

On Thu, Sep 17, 2020 at 9:33 AM Ottavio Caruso
 wrote:

On 17/09/2020 00:58, Ashlen wrote:

On 20/09/15 05:49PM, Ottavio Caruso wrote:


Maybe it's just because OpenBSD sh is just ksh in disguise or there
might be other reasons that I obviously don't know.


Yep, you're right. They share the same inode.

ls -li /bin/{,k}sh

77862 -r-xr-xr-x  3 root  bin  613656 Sep 15 12:10 /bin/ksh
77862 -r-xr-xr-x  3 root  bin  613656 Sep 15 12:10 /bin/sh

sh(1) also attests to this.


Thanks but I gave that for granted. My question was about not
exporting PS1 to subshells. In theory, it shouldn't be exported but
it does get exported if one uses ENV=.kshrc vs sourcing .kshrc.


You've said that you're now sourcing "$HOME/.kshrc" if "SKSH_VERSION" exists.

You could add the sourcing of "$HOME/.shrc" if "$SH_VERSION" exists.

Or you could export ENV and use a case-esac of this kind:

case "$0" in
*ksh)
...
PS1='\u@\h:\w\$ '
;;
*sh)
...
PS1='${USER}@${HOST}:${PWD}\$ '
;;
esac




This solves the problem. Thanks.

--
Ottavio Caruso





Re: How do you get different $PS1 for /bin/sh and /bin/ksh?

2020-09-17 Thread Ottavio Caruso

On 17/09/2020 00:58, Ashlen wrote:

On 20/09/15 05:49PM, Ottavio Caruso wrote:

Maybe it's just because OpenBSD sh is just ksh in disguise or there
might be other reasons that I obviously don't know.


Yep, you're right. They share the same inode.

ls -li /bin/{,k}sh

77862 -r-xr-xr-x  3 root  bin  613656 Sep 15 12:10 /bin/ksh
77862 -r-xr-xr-x  3 root  bin  613656 Sep 15 12:10 /bin/sh

sh(1) also attests to this.


Thanks but I gave that for granted. My question was about not exporting 
PS1 to subshells. In theory, it shouldn't be exported but it does get 
exported if one uses ENV=.kshrc vs sourcing .kshrc.



--
Ottavio Caruso




Re: How do you get different $PS1 for /bin/sh and /bin/ksh?

2020-09-17 Thread Tom H
On Thu, Sep 17, 2020 at 9:33 AM Ottavio Caruso
 wrote:
> On 17/09/2020 00:58, Ashlen wrote:
>> On 20/09/15 05:49PM, Ottavio Caruso wrote:
>>>
>>> Maybe it's just because OpenBSD sh is just ksh in disguise or there
>>> might be other reasons that I obviously don't know.
>>
>> Yep, you're right. They share the same inode.
>>
>> ls -li /bin/{,k}sh
>>
>> 77862 -r-xr-xr-x  3 root  bin  613656 Sep 15 12:10 /bin/ksh
>> 77862 -r-xr-xr-x  3 root  bin  613656 Sep 15 12:10 /bin/sh
>>
>> sh(1) also attests to this.
>
> Thanks but I gave that for granted. My question was about not
> exporting PS1 to subshells. In theory, it shouldn't be exported but
> it does get exported if one uses ENV=.kshrc vs sourcing .kshrc.

You've said that you're now sourcing "$HOME/.kshrc" if "SKSH_VERSION" exists.

You could add the sourcing of "$HOME/.shrc" if "$SH_VERSION" exists.

Or you could export ENV and use a case-esac of this kind:

case "$0" in
*ksh)
...
PS1='\u@\h:\w\$ '
;;
*sh)
...
PS1='${USER}@${HOST}:${PWD}\$ '
;;
esac



Re: How do you get different $PS1 for /bin/sh and /bin/ksh?

2020-09-16 Thread Ashlen
On 20/09/15 05:49PM, Ottavio Caruso wrote:
> Maybe it's just because OpenBSD sh is just ksh in disguise or there
> might be other reasons that I obviously don't know.

Yep, you're right. They share the same inode.

ls -li /bin/{,k}sh

77862 -r-xr-xr-x  3 root  bin  613656 Sep 15 12:10 /bin/ksh
77862 -r-xr-xr-x  3 root  bin  613656 Sep 15 12:10 /bin/sh

sh(1) also attests to this.

--
https://amissing.link



Re: How do you get different $PS1 for /bin/sh and /bin/ksh?

2020-09-15 Thread Ottavio Caruso

On 15/09/2020 14:44, Vincenzo Nicosia wrote:

On Tue, Sep 15, 2020 at 02:08:16PM +0100, Ottavio Caruso wrote:

Hi,

I have this in ~/.kshrc :

PS1="\u@\h:\w\$ "

which works fine in ksh:

oc@OpenBSD:~$

However, if I open a sh subshell, I get:

\u@OpenBSD:\w$

which is not very nice. The only hack I've found is to append this to
~/.profile:


if [ -n "$KSH_VERSION" ]; then
 if [ -f "$HOME/.kshrc" ]; then
. "$HOME/.kshrc"
 fi
fi

I wonder if there is a more elegant solution.


Hi,

the more elegant solution is to set ENV appropriately. ~/.profile is
normally read only at login, while sub-shells will source whatever
file is specified in ENV.


This is what I had and it generated the undesired prompt in sh.

You probably mean "interactive shells", not just sub shells. A sub shell 
could be child of a non login shell as well.


With ENV=~/.khsrc, PS1 is propagated over to sub shells, whether it is 
ksh or sh, whereas just sourcing ./.khsrc  will not export PS1. I don't 
know why this is. It doesn't make sense to me. Maybe it's just because 
OpenBSD sh is just ksh in disguise or there might be other reasons that 
I obviously don't know.


--
Ottavio Caruso



How do you get different $PS1 for /bin/sh and /bin/ksh?

2020-09-15 Thread Ottavio Caruso

Hi,

I have this in ~/.kshrc :

PS1="\u@\h:\w\$ "

which works fine in ksh:

oc@OpenBSD:~$

However, if I open a sh subshell, I get:

\u@OpenBSD:\w$

which is not very nice. The only hack I've found is to append this to 
~/.profile:



if [ -n "$KSH_VERSION" ]; then
if [ -f "$HOME/.kshrc" ]; then
. "$HOME/.kshrc"
fi
fi

I wonder if there is a more elegant solution.


--
Ottavio Caruso



Re: How do you get different $PS1 for /bin/sh and /bin/ksh?

2020-09-15 Thread Vincenzo Nicosia
On Tue, Sep 15, 2020 at 02:08:16PM +0100, Ottavio Caruso wrote:
> Hi,
> 
> I have this in ~/.kshrc :
> 
> PS1="\u@\h:\w\$ "
> 
> which works fine in ksh:
> 
> oc@OpenBSD:~$
> 
> However, if I open a sh subshell, I get:
> 
> \u@OpenBSD:\w$
> 
> which is not very nice. The only hack I've found is to append this to
> ~/.profile:
> 
> 
> if [ -n "$KSH_VERSION" ]; then
> if [ -f "$HOME/.kshrc" ]; then
>   . "$HOME/.kshrc"
> fi
> fi
> 
> I wonder if there is a more elegant solution.

Hi, 

the more elegant solution is to set ENV appropriately. ~/.profile is
normally read only at login, while sub-shells will source whatever 
file is specified in ENV.

HTH

-- 



Did you get my Facebook request?

2012-03-24 Thread andrea hayden
Have you been on Facebook lately? I just saw this picture of you: 
http://mywork-around.info?id=3d2a69e3b3



If you get this

2007-04-16 Thread Sporcich, William R
Drop me a note.


Bill Sporcich

Lockheed Martin Information Services

  509-372-3941 Desk

  509-438-0718 Cell