Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making plushook a bare command (modifying $PATH, take 2) #66

Open
stuartpb opened this issue May 28, 2015 · 6 comments
Open

Making plushook a bare command (modifying $PATH, take 2) #66

stuartpb opened this issue May 28, 2015 · 6 comments

Comments

@stuartpb
Copy link
Member

In response to #15 (comment), and with the current discussion in #65 taken into account, I'm reconsidering the idea of adding plushook's directory (either $PLUSHU_ROOT/lib as it is now, or moving it to $PLUSHU_ROOT/bin or a new directory like $PLUSHU_ROOT/lib/bin) to $PATH.

Unlike the situation when #15 was originally written (and especially its final comment), as detailed in #65, $PLUSHU_ROOT is not a core part of modern Plushu plugin code - in fact, in light of plugin profiles (as implemented circa #41 and #37 (comment)), $PLUSHU_ROOT is almost never referenced after the profile step, apart from calls to plushook.

Implementing this would not only fix one of the longest-standing ugliness/oddities of core Plushu plugin development (the most important command in the entire system being a variable-expanded quoted string), it would also provide a fair degree of flexibility in future refactors (including - holy cow I just realized this - allowing superplugins to override hooks, the long-thought-lost golden-calf-holy-grail of #45).

If implemented, this would be done using $PLUSHU_ROOT at the beginning of plushu - not using the user's home directory, or any Bash profile scripts. (I think part of why #15 was so dubious about modifying $PATH was because I didn't understand how the environment works for the call stack as well back then as I do now.) Moreover, the changing of $PATH like this would probably be implemented as part of what is currently lib/profile.sh, the source fragment script that sets the defaults for $PLUSHU_ROOT and $PLUSHU_USER (to facilitate instances where the Plushu ecosystem has to be entered from the side, like plushu/plushu-startup-deploy-all#2, so that they will work just as seamlessly).

@stuartpb
Copy link
Member Author

$PLUSHU_ROOT is almost never referenced after the profile step, apart from calls to plushook.

Not that this is entirely material to this consideration, but this assertion should be backed up with the output from a grep like #65 (comment)

@stuartpb
Copy link
Member Author

Also, I want to take a second and say, whichever way this issue breaks, I made the right call in #15, since making this decision too hastily would have broken backward compatibility if I decided it was a mistake down the line - if this change is implemented, it can be rolled out gradually, with the old convention remaining (for the foreseeable future) forward-compatible.

@stuartpb
Copy link
Member Author

Okay, I just did a quick preliminary test of this on sandbox with sed -i 's#"$PLUSHU_ROOT/lib/plushook"#plushook#g' /home/plushu/plugins/*/hooks/*/*, and after a quick-and-dirty hotpatch implementation to finish plushu/plushu-startup-deploy-all#2, everything appears to be working fine.

@stuartpb
Copy link
Member Author

stuartpb commented Jun 7, 2015

Actually, I'm thinking something more like this:

  • Plushu "interface commands" (things like plushook that are meant to be used by plugins) should be placed in $PLUSHU_ROOT/bin. (If anybody else were using this, I would add a symlink from $PLUSHU_ROOT/lib/plushook to $PLUSHU_ROOT/bin/plushook.) They should be called by env path resolution (so no location prefix).
  • Plushu internal commands (the things you might put in a sourced function, like the thing that lists all the scripts for a hook across all plugins in numerically-sorted order, for use only internally in Plushu core stuff) would be what goes in $PLUSHU_ROOT/lib, and those scripts would still be called by absolute path.

@stuartpb
Copy link
Member Author

stuartpb commented Jun 8, 2015

Note that there's some other really interesting discussion about the future of plushook happening in #62

@stuartpb
Copy link
Member Author

stuartpb commented Jun 8, 2015

Moving the sorted-plugin-file-listing (with an arbitrary parameter for the part that is currently hardcoded to hooks) would be useful for #62 stuff, as well as potentially some stuff around profiles and/or command scripts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant