home | list info | list archive | date index | thread index

Re: [OCLUG-Tech] am i just misunderstanding how the "source" command works?

  • Subject: Re: [OCLUG-Tech] am i just misunderstanding how the "source" command works?
  • From: "Robert P. J. Day" <rpjday [ at ] crashcourse [ dot ] ca>
  • Date: Sat, 15 Mar 2014 09:38:29 -0400 (EDT)
On Sat, 15 Mar 2014, Richard Guy Briggs wrote:

> On 14/03/15, Robert P. J. Day wrote:
> >
> >   currently playing with fedora (pre-21) rawhide, went to start
> > mariadb server:
> >
> >   # systemctl start mariadb-server
> >
> > and got (from output of "journalctl"):
> >
> > mariadb-check-socket[3942]: /usr/libexec/mariadb-check-socket: line 8: ./mariadb-scripts-common: No such file or directory
> > systemd[1]: mariadb.service: control process exited, code=exited status=1
> > systemd[1]: Failed to start MariaDB database server.
> >
> >   so i checked the script /usr/libexec/mariadb-check-socket and, sure
> > enough, line 8:
> >
> >   source ./mariadb-scripts-common
>
> What was the working directory of that script?

  which script? i invoked the "systemctl" command from a totally
different directory, so i'm simply assuming that the
mariadb-check-socket script has a working directory that is
*not* /usr/libexec when it's being invoked; hence, the failure.

> > but i'm fairly sure the "source" command uses the PATH variable to
> > find scripts to source,
>
> Not if it is prefixed by "./".  That will anchor that script in the pwd
> of the running script (which could change during its execution).

  quite so, bad choice of words on my part.

> > and there's no guarantee the above would work, even when that
> > "common" script to be sourced is in the same directory as the
> > sourcing script, isn't that correct?
>
> So say that script is in the same directory as the calling script
> and in the calling script, a "cd <mumble>" command is executed?
>
> >   as a hacky test, i edited the sourcing script and changed that
> > line to:
> >
> >   source /usr/libexec/mariadb-scripts-common
>
> I would use instead a local variable in the script that records the
> starting working directory of that script and then prepend that
> variable to that script name.

  right ... which is what other scripts in /usr/libexec seem to be
doing.

> >   the above strikes me as simply a bug ... am i missing something
> > here that would allow the original sourcing script to work
> > properly? i'm about ready to file a bug report.
>
> I would certainly say it is a bug one way or another.

  i already filed it:

https://bugzilla.redhat.com/show_bug.cgi?id=1076823

so we'll see what response i get.

rday

p.s. i was puzzled as to how something so trivially wrong(?) could
have lasted for any length of time, but checking the git repo for
mariadb source shows that it's a fairly recent addition. still, seems
like something a really simple test should have caught.

-- 

========================================================================
Robert P. J. Day                                 Ottawa, Ontario, CANADA
                        http://crashcourse.ca

Twitter:                                       http://twitter.com/rpjday
LinkedIn:                               http://ca.linkedin.com/in/rpjday
========================================================================