Need help with Bash M-code

  • spumco
  • Away
  • Platinum Member
  • Platinum Member
More
31 Mar 2026 16:14 #344995 by spumco
Need help with Bash M-code was created by spumco
Working on a switchable kinematics for my lathe, using the millturn example on GH.

(more here:  forum.linuxcnc.org/10-advanced-configura...r-than-x-axis#344888 )

One part of the switchkins process are a pair of M-codes: M128 and M129.  I gather these are used to change the axis max/min limits when the respective joints are swapped.

Problem is I don't understand the Bash language/terms/syntax well enough to make sure I'm modifying it appropriately for my config.

Here's the full M128:
Warning: Spoiler!


Question(s):

1.  Do I need to change (INI_FILE_NAME) to my particular ini file name, or is this some sort of 'points to the configuration's INI file regardless of name' programming thing?

2.  Under #RESTORE, there is the foreach | $coords... part.
- Does this call, or otherwise ensure, everything below applies to all values after set coords "x y z" at the top?

- Does set L [string toupper $l] somehow change the lowercase "x y z" to upper-case for use in the ::AXIS_[set L]... part?

- What is "catch"?

3.  Could this have been written more simply?
like: hal setp ini.x.min_limit [set ::AXIS_X(MIN_LIMIT)]

and repeated for desired axes?  With no "set coords" or "foreach" or "set L" needed?

Bonus Question:
- Other than to confuse non-programmers, what purpose does this complication serve?  Is the intent to make it so the end-user only has to change the coords "n n n" values and everything still works?

Please Log in or Create an account to join the conversation.

  • spumco
  • Away
  • Platinum Member
  • Platinum Member
More
02 Apr 2026 04:20 #345047 by spumco
Replied by spumco on topic Need help with Bash M-code
Solved.

Short answer(s) for anybody in the future reading this:
  1. No, do not need to change (INI_FILE_NAME)
  2. Yes, yes, and I no longer care what "catch" does.
  3. Yes.  You can just write each hal command line out in a readable form.
  4. Yes, the way it's written permits changing "x y z" at the top and everything below gets sorted out.  Clever, but miserable for us Luddites to unravel.
The following user(s) said Thank You: tommylight

Please Log in or Create an account to join the conversation.

Time to create page: 0.072 seconds
Powered by Kunena Forum