Skip to main content
added 763 characters in body
Source Link

I need, when generating Java keystores (which I do frequently), to generate them under the Java 8 version of Keytool. If I use the keytool in the default Java version, they are incompatible with the Java on the target systems we manage.

I've figured out a way to do this, with a wrapper shell script (currently called "keytool8"). And that shell script echoes a message indicating that it's using the Java 8 keytool, before handing off to that keytool.

And I have the shell script in a directory that's in my path.

But if I rename it to "keytool," and type "keytool" from a command line, I still get the default keytool.

Is there a way for my shell script to preempt the default keytool?

MORE INFORMATION, 9/11/2023

I added "/Users/jameslampert/Applications" (the directory where I put my script) to my /etc/paths, so that it now looks like:

/Users/jameslampert/Applications
/usr/local/bin
/System/Cryptexes/App/usr/bin
/usr/bin
/bin
/usr/sbin
/sbin

and now "echo $PATH" produces

/opt/homebrew/bin:/opt/homebrew/sbin:/Users/jameslampert/.nvm/versions/node/v16.0.0/bin:/Users/jameslampert/Applications:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin

If I do "which keytool," I get:

/usr/bin/keytool

Somehow, the default keytool is preempting me, even though /usr/bin is theoretically after /Users/jameslampert/Applications in the path.

I need, when generating Java keystores (which I do frequently), to generate them under the Java 8 version of Keytool. If I use the keytool in the default Java version, they are incompatible with the Java on the target systems we manage.

I've figured out a way to do this, with a wrapper shell script (currently called "keytool8"). And that shell script echoes a message indicating that it's using the Java 8 keytool, before handing off to that keytool.

And I have the shell script in a directory that's in my path.

But if I rename it to "keytool," and type "keytool" from a command line, I still get the default keytool.

Is there a way for my shell script to preempt the default keytool?

I need, when generating Java keystores (which I do frequently), to generate them under the Java 8 version of Keytool. If I use the keytool in the default Java version, they are incompatible with the Java on the target systems we manage.

I've figured out a way to do this, with a wrapper shell script (currently called "keytool8"). And that shell script echoes a message indicating that it's using the Java 8 keytool, before handing off to that keytool.

And I have the shell script in a directory that's in my path.

But if I rename it to "keytool," and type "keytool" from a command line, I still get the default keytool.

Is there a way for my shell script to preempt the default keytool?

MORE INFORMATION, 9/11/2023

I added "/Users/jameslampert/Applications" (the directory where I put my script) to my /etc/paths, so that it now looks like:

/Users/jameslampert/Applications
/usr/local/bin
/System/Cryptexes/App/usr/bin
/usr/bin
/bin
/usr/sbin
/sbin

and now "echo $PATH" produces

/opt/homebrew/bin:/opt/homebrew/sbin:/Users/jameslampert/.nvm/versions/node/v16.0.0/bin:/Users/jameslampert/Applications:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin

If I do "which keytool," I get:

/usr/bin/keytool

Somehow, the default keytool is preempting me, even though /usr/bin is theoretically after /Users/jameslampert/Applications in the path.

Source Link

I would like to preempt a command on my mac (specifically, Keytool)

I need, when generating Java keystores (which I do frequently), to generate them under the Java 8 version of Keytool. If I use the keytool in the default Java version, they are incompatible with the Java on the target systems we manage.

I've figured out a way to do this, with a wrapper shell script (currently called "keytool8"). And that shell script echoes a message indicating that it's using the Java 8 keytool, before handing off to that keytool.

And I have the shell script in a directory that's in my path.

But if I rename it to "keytool," and type "keytool" from a command line, I still get the default keytool.

Is there a way for my shell script to preempt the default keytool?