Uploaded image for project: 'RHEL'
  1. RHEL
  2. RHEL-5689

source file-in-current-directory

    • Icon: Bug Bug
    • Resolution: Not a Bug
    • Icon: Normal Normal
    • None
    • rhel-8.4.0
    • ksh
    • None
    • Moderate
    • sst_cs_plumbers
    • ssg_core_services
    • None
    • False
    • Hide

      None

      Show
      None
    • None
    • None
    • None
    • None
    • If docs needed, set a value
    • None

      This bug was initially created as a copy of Bug #2010398

      I am copying this bug because:

      Sample reproducer:

      << rhel5 and any bash version go to $HOME or directory not in $PATH >>

      $ cd
      $ cat > a <<EOF
      echo foo
      EOF
      $ source a
      foo

      << rhel6 and newer with ksh after creating the file to be sourced >>
      $ source a
      ksh: .: a: cannot open [No such file or directory]

      but bash works, and is documented to do so.

      The code is basically identical from rhel5 to rhel7, major difference is:

      https://github.com/ksh93/ksh/blame/master/src/cmd/ksh93/sh/path.c#L403

      that is, newer ksh has:

      if(pp->flags&PATH_SKIP)
      return(ppnext);

      and older ksh has:

      if(pp->flags&PATH_SKIP)
      continue;

      there is nothing useful in git blame or changelog that I could see.

      What was noticed is that on older ksh when traversing pp
      (shp->pathlist), due to the 'do {} while' in path_opentype, it eventually
      calls sh_open with just the file name, not a prefix, while on newer ksh, it
      calls sh_open twice with the last component in the $PATH.

      This makes ksh different from bash, and cause the source command to require
      '.' in $PATH to be able to source files in the current directory.

              vmihalko Vincent Mihalkovic
              rhn-support-pandrade Paulo Andrade
              Vincent Mihalkovic Vincent Mihalkovic
              Karel Volný Karel Volný
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: