LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 02-23-2021, 08:24 AM   #1
M0M0
Member
 
Registered: Sep 2020
Location: Germany
Distribution: Slackware
Posts: 230

Rep: Reputation: 20
sh is a symlink to bash but man sh shows man page of ksh


I just noticed that, wouldn't it make more sense to show the man page of bash instead?
 
Old 02-23-2021, 09:36 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,976

Rep: Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337
no, the shell (and other programs) may detect their invocation and behave accordingly. so sh and bash work differently.
 
Old 02-23-2021, 09:39 AM   #3
M0M0
Member
 
Registered: Sep 2020
Location: Germany
Distribution: Slackware
Posts: 230

Original Poster
Rep: Reputation: 20
ok, but sh does definitely not behave like ksh.
 
Old 02-23-2021, 09:42 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,976

Rep: Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337Reputation: 7337
see man bash
Quote:
If bash is invoked with the name sh, it tries to mimic the startup behavior of historical versions of sh as closely as possible, while conforming to the POSIX standard as well.
Yes, that is probably a misconfiguration of man pages.
 
Old 02-23-2021, 09:47 AM   #5
ponce
LQ Guru
 
Registered: Aug 2004
Location: Pisa, Italy
Distribution: Slackware
Posts: 7,117

Rep: Reputation: 4192Reputation: 4192Reputation: 4192Reputation: 4192Reputation: 4192Reputation: 4192Reputation: 4192Reputation: 4192Reputation: 4192Reputation: 4192Reputation: 4192
I can replicate this on an updated machine, while on a fresh installed one (a couple of hours ago)
Code:
$ man sh
No manual entry for sh
 
Old 02-23-2021, 12:08 PM   #6
bassmadrigal
LQ Guru
 
Registered: Nov 2003
Location: West Jordan, UT, USA
Distribution: Slackware
Posts: 8,792

Rep: Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656
Quote:
Originally Posted by ponce View Post
I can replicate this on an updated machine, while on a fresh installed one (a couple of hours ago)
Code:
$ man sh
No manual entry for sh
I also don't have a man page for sh on my 14.2 install, but if I check on my htpc using an old version of -current (from around May 2019), that does bring up ksh's man page.

If I run man -w sh, it shows /usr/man/man1/ksh.1.gz

I'm not sure if that's a glitch with an older version of man or if there's something like a symlink that allows man to link to ksh when running it against sh.
 
Old 02-23-2021, 12:30 PM   #7
drumz
Member
 
Registered: Apr 2005
Location: Oklahoma, USA
Distribution: Slackware
Posts: 906

Rep: Reputation: 697Reputation: 697Reputation: 697Reputation: 697Reputation: 697Reputation: 697
Quote:
Originally Posted by bassmadrigal View Post
I also don't have a man page for sh on my 14.2 install, but if I check on my htpc using an old version of -current (from around May 2019), that does bring up ksh's man page.

If I run man -w sh, it shows /usr/man/man1/ksh.1.gz

I'm not sure if that's a glitch with an older version of man or if there's something like a symlink that allows man to link to ksh when running it against sh.
I agree, on my 14.2 install:

Code:
$ man sh
No manual entry for sh
But on Pop!_OS 20.04 LTS (derivative of Ubuntu):

Code:
$ man -w sh
/usr/share/man/man1/dash.1.gz
$ find /usr/share/man -iname sh.*
/usr/share/man/man1/sh.1.gz
/usr/share/man/man1/sh.distrib.1.gz
$ ls -l /usr/share/man/man1/sh.1.gz 
lrwxrwxrwx 1 root root 9 Jul 18  2019 /usr/share/man/man1/sh.1.gz -> dash.1.gz
$ ls -l /usr/share/man/man1/sh.distrib.1.gz 
lrwxrwxrwx 1 root root 9 Jan 25  2018 /usr/share/man/man1/sh.distrib.1.gz -> dash.1.gz
So I'm guessing a symlink was created at some point on -current. Maybe try searching in /var/log/scripts and/or /var/log/removed_scripts/ ?
 
Old 02-23-2021, 01:08 PM   #8
Petri Kaukasoina
Senior Member
 
Registered: Mar 2007
Posts: 1,849

Rep: Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520
The start of the ksh man page talks something about sh.
Code:
$ gzip -dc /usr/man/man1/ksh.1.gz |head -46
.\"
.\" David Korn
.\" AT&T Bell Laboratories
.\"
.\" @(#)sh.1 (dgk@research.att.com) 12/28/93
.\"
.nr Z 1 \" set to 1 when command name is ksh, 2 for ksh93
.ds OK [\|
.ds CK \|]
.ds ' \s+4\v@.3m@\'\v@-.3m@\s-4
.ds ` \s+4\v@.3m@\`\v@-.3m@\s-4
.if \nZ=0  \{\
.TH SH 1
.\}
.if \nZ=1 \{\
.TH KSH 1
.\}
.if \nZ=2 \{\
.TH KSH93 1
.\}
.SH NAME
.if \nZ=0 \{\
sh, rsh, pfsh \- shell, the standard/restricted command and programming language
.\}
.if \nZ=1 \{\
ksh, rksh, pfksh \- KornShell, a standard/restricted command and programming language
.\}
.SH NOTE
Currently,
.I rksh
and
.I pfksh
are not available on macOS / Darwin.
.if \nZ=2 \{\
ksh93, rksh93, pfksh93 \- KornShell, a standard/restricted command and programming language
.\}
.SH SYNOPSIS
.if \nZ=0 \{\
.B sh
.\}
.if \nZ=1 \{\
.B ksh
.\}
.if \nZ=2 \{\
.B ksh93
.\}
/usr/bin/mandb puts it in /var/cache/man/usr-man/index.db. There is a script /etc/cron.daily/man-db that cron runs at 4:40 every night.

Last edited by Petri Kaukasoina; 02-23-2021 at 01:30 PM.
 
Old 02-23-2021, 02:24 PM   #9
bassmadrigal
LQ Guru
 
Registered: Nov 2003
Location: West Jordan, UT, USA
Distribution: Slackware
Posts: 8,792

Rep: Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656
Quote:
Originally Posted by drumz View Post
I agree, on my 14.2 install:

Code:
$ man sh
No manual entry for sh
But on Pop!_OS 20.04 LTS (derivative of Ubuntu):

Code:
$ man -w sh
/usr/share/man/man1/dash.1.gz
$ find /usr/share/man -iname sh.*
/usr/share/man/man1/sh.1.gz
/usr/share/man/man1/sh.distrib.1.gz
$ ls -l /usr/share/man/man1/sh.1.gz 
lrwxrwxrwx 1 root root 9 Jul 18  2019 /usr/share/man/man1/sh.1.gz -> dash.1.gz
$ ls -l /usr/share/man/man1/sh.distrib.1.gz 
lrwxrwxrwx 1 root root 9 Jan 25  2018 /usr/share/man/man1/sh.distrib.1.gz -> dash.1.gz
So I'm guessing a symlink was created at some point on -current. Maybe try searching in /var/log/scripts and/or /var/log/removed_scripts/ ?
I did forget to mention that on my old -current system, there is no file or symlink for sh.1.gz, so I'm not sure how it links to ksh.1.gz when you run man -w sh
 
Old 02-23-2021, 02:33 PM   #10
Petri Kaukasoina
Senior Member
 
Registered: Mar 2007
Posts: 1,849

Rep: Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520
Quote:
Originally Posted by bassmadrigal View Post
I did forget to mention that on my old -current system, there is no file or symlink for sh.1.gz, so I'm not sure how it links to ksh.1.gz when you run man -w sh
Via /var/cache/man/usr-man/index.db
 
Old 02-23-2021, 02:45 PM   #11
bassmadrigal
LQ Guru
 
Registered: Nov 2003
Location: West Jordan, UT, USA
Distribution: Slackware
Posts: 8,792

Rep: Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656
But if I don't have any sh.1.gz file or symlink, how did sh get mapped to ksh on my old -current? And why did 14.2 not have that happen and why does it not happen with a fresh install of -current?

I don't know a lot about man and how the index.db is created.
 
Old 02-23-2021, 02:58 PM   #12
Petri Kaukasoina
Senior Member
 
Registered: Mar 2007
Posts: 1,849

Rep: Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520
Quote:
Originally Posted by bassmadrigal View Post
But if I don't have any sh.1.gz file or symlink, how did sh get mapped to ksh on my old -current? And why did 14.2 not have that happen and why does it not happen with a fresh install of -current?

I don't know a lot about man and how the index.db is created.
See https://www.linuxquestions.org/quest...9/#post6223702
Your new -current has not been on at 4:40 yet?
Slackware 14.2 did not have man-db:
Code:
Wed Nov 29 08:15:09 UTC 2017
ap/man-1.6g-x86_64-3.txz:  Removed.
ap/man-db-2.7.6.1-x86_64-1.txz:  Added.
  This package replaces the good old man package. Thanks to B. Watson.
 
Old 02-23-2021, 03:30 PM   #13
bassmadrigal
LQ Guru
 
Registered: Nov 2003
Location: West Jordan, UT, USA
Distribution: Slackware
Posts: 8,792

Rep: Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656
ponce is the one who stated that a new install didn't show the issue, but looking at the doinst.sh, it seems database creation is commented out, so it wouldn't happen until cron is run at 4:40.

So, since you simply linked your old post when I asked how it happened, I'm assuming man-db actually looks in the man pages to generate its index rather than just filenames? I didn't know how the database was created, which is why I asked. Looking in the bash.1.gz file, there's also mentions of sh, so I'm not sure what portions man-db looks at to generate its cache. It seems most distros just symlink sh.1.gz with the system's preferred shell (and maybe that's the best option here if ksh.1.gz maps itself to sh because of text inside the man file).
 
Old 02-23-2021, 03:46 PM   #14
Petri Kaukasoina
Senior Member
 
Registered: Mar 2007
Posts: 1,849

Rep: Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520Reputation: 1520
Quote:
Originally Posted by bassmadrigal View Post
So, since you simply linked your old post when I asked how it happened, I'm assuming man-db actually looks in the man pages to generate its index rather than just filenames? I didn't know how the database was created, which is why I asked.
Yes, I guess so. I think it's these two lines in my post:
Code:
.SH NAME
sh, rsh, pfsh \- shell, the standard/restricted command and programming language
Actually, it's inside an if Z=0, but it seems mandb does not take into account that Z=1. If it did, it would use this:
Code:
.SH NAME
ksh, rksh, pfksh \- KornShell, a standard/restricted command and programming language
("man pfsh" shows the man page, but "man pfksh" does not.)

Last edited by Petri Kaukasoina; 02-23-2021 at 03:56 PM.
 
Old 02-23-2021, 04:29 PM   #15
bassmadrigal
LQ Guru
 
Registered: Nov 2003
Location: West Jordan, UT, USA
Distribution: Slackware
Posts: 8,792

Rep: Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656
Quote:
Originally Posted by Petri Kaukasoina View Post
Yes, I guess so. I think it's these two lines in my post:
Code:
.SH NAME
sh, rsh, pfsh \- shell, the standard/restricted command and programming language
Actually, it's inside an if Z=0, but it seems mandb does not take into account that Z=1. If it did, it would use this:
That line seems to be the cause because man pfsh also shows ksh (an rsh man page actually exists and loads using man rsh, so it looks like man-db will prioritize files over one commands specified in a man page).

Seems like if we want man sh to show bash (since that is the default shell), the best option would be to simply create a symlink for /usr/man/man1/sh.1.gz pointing to /usr/man/man1/bash.1.gz
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] KSH script error -ksh: .: syntax error: `<<' unmatched Cheryl_A Linux - Server 2 01-24-2018 10:27 AM
[SOLVED] Symlink to html file shows a blank page in browser jbruyet Linux - Software 2 09-28-2012 02:13 PM
Question How to get stat() of symlink and not of target of symlink ? ronbarak Programming 3 11-08-2010 12:14 PM
"info ls" shows man page instead of info page lorenz Slackware 8 09-21-2007 08:47 PM
Is there a man page on how to use man page? jdruin Linux - Software 2 10-30-2004 09:29 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 07:23 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration