0

I am trying to figure out how the dot command behaves under /bin/sh, i.e.

. sourcedfile

but I am having trouble finding it. I can find other builtins like cd with man, e.g.

man cd

but I am not sure what to enter for the dot command (man . doesn't work). The online docs to the UNIX System Services Command Reference didn't seem to have anything either.

mike
  • 819
  • 4
  • 14
  • After some hunting, I found some doc in the POSIX sh description: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09 Search for: dot - execute commands in the current environment which says: "If file does not contain a , the shell shall use the search path specified by PATH to find the directory containing file..." – mike Jun 02 '23 at 20:37
  • What I don't know is if tcsh 'dot command' is exactly conformant with the POSIX definition? I know bash is 'different' by default – mike Jun 02 '23 at 20:38
  • I'm not used to `tcsh`. Anyway, the only thing I found about `tcsh`, and file sourcing is the `source` tcsh built-in (in the book you listed). Interestingly, when I try `. test.sh` under tcsh, I'm getting `/bin/.: EDC5111I Permission denied..` This looks to me as if `tcsh` does not support `.` as "sourcing built-in", but has an own built-in called `source`. Unfortunately, this built-in is only very briefly explained in the manual. – phunsoft Jun 03 '23 at 20:25
  • I just saw this at the start of the z/OS shell description: The z/OS shell is based on the KornShell that originated on a UNIX system. As implemented for z/OS UNIX System Services, this shell conforms to POSIX standard 1003.2-1992. – mike Jun 04 '23 at 21:38
  • This documentation on ksh: https://www.mkssoftware.com/docs/man1/dot.1.asp does seem to match what I'm seeing. – mike Jun 04 '23 at 21:43
  • The standard shell `/bin/sh` was original ported by Mortice Kern Co. from their korn shell. You were asking about the C shell `/bin/tcsh`, which is the second shell that is part of z/OS. The bash shell is available, too, but is not part of the z/OS discribution. – phunsoft Jun 08 '23 at 15:33

1 Answers1

2

csh and tcsh don't have a . command; it only has source command, which does the same.

The standard tcsh manpage describes the builtins in the tcsh manpage, but it seems that on zOS this is split to different pages; there's a list here.

You should never use the POSIX sh documentation for csh; while it's superficially similar there are also many differences, and it's just a different shell.


It's also generally discouraged to use tcsh, as it has a number of limitations such as lack of functions, limited redirection, limited parser, and a few others that tend to cause a world of pain for non-trivial scripts.

Martin Tournoij
  • 26,737
  • 24
  • 105
  • 146
  • Your answer is correct. I asked the wrong question, thinking that the /bin/sh shell was tcsh when it appears to be a variant of 'korn shell'. See my update and comment – mike Jun 04 '23 at 21:41
  • Once I realized where I was off base from your comments, I finally found the dot command: https://www.ibm.com/docs/en/zos/2.5.0?topic=descriptions-dot-run-shell-file-in-current-environment – mike Jun 04 '23 at 21:48