💾 Archived View for thrig.me › blog › 2023 › 07 › 08 › the-ksh-dot-builtin.gmi captured on 2023-07-10 at 13:41:26. Gemini links have been rewritten to link to archived content
-=-=-=-=-=-=-
$ pwd /home/jmates $ file .profile .profile: ASCII text $ . .profile ksh: .: .profile: not found
This is ksh working as intended. The "." or dot builtin performs a PATH search and a .profile file has not been found in any PATH directory. Someone thought that a PATH search was the correct thing for the dot builtin to do, so here we are.
$ source ksh: source: not found
The source builtin comes from a different shell, csh, though has been pilfered into various modern bournelike shells. But maybe not various ksh flavors. Modern is a perhaps dubious term given that some bournelike shells such as ZSH date to 1990. Remember Yugoslavia?
Anyways, the dot builtin needs a fully qualified path to not do a PATH search, similar to using a fully qualified path to a command. A more correct way to load ~/.profile in a ksh would run along the lines of the following.
$ . ~/.profile
Use process tracing. This may also help in the fairly common case of there not being documentation or the documentation sucking. A string that is easy to grep for can help filter out noise.
$ ktrace ksh -c '. easytogrepfor' ksh: .: easytogrepfor: not found $ kdump | fgrep easytogrepfor ...
Someone looking at the trace results would need to know enough about unix to recognize that a PATH search was being done. This may help narrow down what to look for in the documentation. Searching only for paragraphs that mention "PATH" yields much less to read:
$ man ksh | col -bx | wc 2999 20481 150488 $ man ksh | col -bx | perl -00 -nle 'print if /PATH/' | wc 172 1488 10499