Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6680151
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:26:29+00:00 2026-05-26T04:26:29+00:00

I was digging through mysql_safe (trying to add some options) and I came across

  • 0

I was digging through mysql_safe (trying to add some options) and I came across this bash scripting technique they use to assign variables from the Launch Agent:
com.mysql.mysqld.plist (I’m on a mac).

Now mysqld_safe doesn’t know it’s being invoked by LaunchCtl, so I assume any options are converted by LaunchCtl into command line arguments, but I found this sytnax intruiging.
Anyone know how this works?

I understand the basics of Case/Switch in Bash:

case "$myval" in
  switch1) do something;;
  switch2) do something;;
        *) do whatever fallthrough logic;;
esac      

with the default fall through using *
In the script chunk below, the arg value is:
“–basedir=” or “–datadir=” or “–pid-file=”, etc
But WHAT IS UP WITH THE * in there?
Is that a Regular Expression in Switch Statement??
WITH A BACKREFERENCE?

for arg do
  # the parameter after "=", or the whole $arg if no match
  val=`echo "$arg" | sed -e 's;^--[^=]*=;;'`
  # what's before "=", or the whole $arg if no match
  optname=`echo "$arg" | sed -e 's/^\(--[^=]*\)=.*$/\1/'`
  # replace "_" by "-" ; mysqld_safe must accept "_" like mysqld does.
  optname_subst=`echo "$optname" | sed 's/_/-/g'`
  arg=`echo $arg | sed "s/^$optname/$optname_subst/"`
  arg=`echo $arg | sed "s/^$optname/$optname_subst/"`
  case "$arg" in
    # these get passed explicitly to mysqld
    --basedir=*) MY_BASEDIR_VERSION="$val" ;;
    --datadir=*) DATADIR="$val" ;;
    --pid-file=*) pid_file="$val" ;;
    --plugin-dir=*) PLUGIN_DIR="$val" ;;
    --user=*) user="$val"; SET_USER=1 ;;
    ...
    ...
    *)
      if test -n "$pick_args"
      then
        append_arg_to_args "$arg"
      fi
      ;;
  esac
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T04:26:30+00:00Added an answer on May 26, 2026 at 4:26 am

    They aren’t regular expressions; they’re filename expansion patterns, also known as “globs”.

    * matches zero or more arbitrary characters, and ? matches any single character.

    For more information: http://www.gnu.org/s/bash/manual/bash.html#Pattern-Matching

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was just digging through some JavaScript code (Raphaël.js) and came across the following
I have been digging through some ruby gem code and i came across these
I wanted to use this gem: https://github.com/PRX/apn_on_rails Finally, after digging through the issues, seems
I was digging around on some HTML on a webpage and saw this: <!DOCTYPE
I've been really digging into LINQ, and I'm trying to hash out this lambda
While digging through some old code put together by a former co-worker who's talents
Whilst digging through the STL sources (DinkumWare, SGI, STLport, etc..) and trying to make
I have digging through the C# code generated by SWIG for Quantlib and came
I was digging through some code, and I found some calls to mySQL_fetch_array .
we are currently digging through some really old C++/CLI-Code (Old Syntax .NET Beta) and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.