Replies: 16 comments 7 replies
-
I think for this to work the framework will need to be installed global and have some kind of basher style package manager. In the include function it could look for a file called "main.sh" that would export the module to use in the installed packaged. |
Beta Was this translation helpful? Give feedback.
-
Having a little look around I think it would be a good idea to make it compatible with bpkg. https://github.com/bpkg/bpkg |
Beta Was this translation helpful? Give feedback.
-
Thanks for joining the discussion @AdeAttwood.
I'm also not entirely convinced about some of their decisions, like the one to use JSON to describe the package. It makes it easier for those coming from the NPM world, but on the other hand adds complexity (JSON parser) that could have been avoided. It would be great for a potential package manager to support monorepo-style packages (many packages per repo). This makes it easier to create micro-libraries from individual helper utilities, and is generally what helped JavaScript become what it is now. Some features would definitely have to be globally available (e.g. parametrized functions, module system), but that's a given in most languages anyway, but we could still keep many features in silos, if possible. |
Beta Was this translation helpful? Give feedback.
-
Basher was the other one I have looked into. Not sure its what you looking for though. Maby create a merge of the two. Form bpkg I like https://github.com/bpkg/bpkg#package-exports for exporting or running. And also the config file defining the bin files rather than an install script. |
Beta Was this translation helpful? Give feedback.
-
These are some really nice points. I will devote some time this weekend to lay my thoughts and feedback. |
Beta Was this translation helpful? Give feedback.
-
Hii, i'm following this project for quite a time and it's a really project :D There is just one thing, i would even try to implement a web framework or classes into it. https://github.com/yoctu/yosh I have some other projects wroten in my framework but they're still close, they will be probably open this mounth. |
Beta Was this translation helpful? Give feedback.
-
Before diving into the actual discussion, I believe it is important to acknowledge what bash is. This means that what we do should also be "bash-y", there is no reason to force OO if it feels unnatural/problematic or other project practices, eg configuration storing in json or yaml files. Also, I think that it would be beneficial to move in a 'set requirements first, implement after' fashion. Plus, whatever we decide to implement should be of coming from an actual need and practical use case, to avoid creating a framework that is of no use. Bash Infinity has already done a great job in that aspect, so let's keep the standard up! What is a Bash FrameworkThere seem to be 3 types of bash frameworks. One common type is a collection of functions, aliases, etc to make life in the terminal (and perhaps writing scripts) easier. The second type is frameworks that provide a mechanism into which to hook to get your application running, like the go-script-bash framework. Finally, there are frameworks that intervene in the way you write bash code. This is were we are. I mention this to make clear what should go into Bash Infinity and what not. For instance, it does not make sense to have eg a git module. To answer to @dzove855 , your project seems to me like sth that would be better written in Bash Infinity, than be part of its core. This means that parts of your project could be replaced by (or contributed to) Bash Infinity's core. Module SystemI think that there are three, though tightly related, things here. One is essentially a package/module manager, the second is a spec on how to interact with the packages/modules and third is our implementation of that spec. I think that we shouldn't try to do all three in the context of this single project, especially if we aim to bring interoperability into the bash ecosystem of projects. I propose the following action plan:
Some questions that would need to be addressed by the spec would be:
Also relating to the package manager implementation:
The module system you have posted looks great and we could start with this while developing version 3. But for instance this line: local path="${1}" needs the above discussion to be settled first, IMO. Features from 2.0I agree on your shortlisted features to aim for initially. For me, what bash programming is all about is basically commands and functions. We should focus on interacting with them as easy and intuitive as possible. In the mean time, we could start developing the framework library of helper functions (eg for string manipulation) as the needs we encounter come. FunctionsLet's start with functions, that practically means passing arguments and getting output. For argument passing, the main pain points for me are:
The current notation of Bash Infinity is excellent, but maybe limits the implementation possibilities. Let's work on your code in #41 and research the possibility of backwards compatibility. For getting output from a function there are 3 possibilities (that I know of) in bash:
I would like to have sth that makes this as simple as possible, without messing the scope of variables. I have some ideas to test out. Error reportingBash Infinity currently prints a fancy call stack. This is helpful. But I often find myself wanting to:
Moreover, when trying to debug a script, Bash Inifinity internals get a lot in the way. For instance, running with Working on this and porting parts of the existing stack trace will also be a good opportunity to work on the UI stuff. Sth related is error logging. Contrary to error reporting which is useful for interactive sessions, logging is a second channel of error output. Bash Infinity has some kind of logging, but it feels a little incomplete, am I wrong? These will keep us busy for a while. Then, we can look into variable typing, code structures, etc. I suggest we keep this discussion here. After we conclude on the requirements, we can break them into issues, set some milestones and keep track of the progress there. The next 2-3 weeks will be really busy at work, so my presence here will be sub-optimal, but I will try my best to keep things moving. |
Beta Was this translation helpful? Give feedback.
-
Hi guys, I want just to come with an idea. For example: |
Beta Was this translation helpful? Give feedback.
-
From @adudek #69 (comment)
|
Beta Was this translation helpful? Give feedback.
-
BTW as for unit tests, I also like https://github.com/kward/shunit2/ very much. It is basically a more "traditional" version where not each line is an assertion. |
Beta Was this translation helpful? Give feedback.
-
I got drawn by other stuff, but here is a small draft I created on named parameters. I "stole" this wonderful macro snippet. What do you think? |
Beta Was this translation helpful? Give feedback.
-
That would be very valuable, since many non-trivial scripts require a form or another of CLI args handling. |
Beta Was this translation helpful? Give feedback.
-
I've been doing a lot of Bash lately, brainstorming (and implementing) what hypermodern Bash scripts could look like, and stumbled upon this thread. I would like to share my thoughts as well as provide feedback on these great ideas. There are a lot of "necessities" that are absent from Bash and agreeing on / standardizing these (ex. error reporting, cli parsing) in the name of interoperability would be very useful and provide clarity to the ecosystem as a whole Module / function loading
I like the idea of having a function just for loading a 'module' or 'package'. To me, this seems like a hard requirement if we want to be sure functions from modules are called with the correct context. For example, if we assume there exists some repository from GitHub is properly installed with a call() {
...
PATH="$A_PARTICULAR_MODULES_PATH" "$@"
}
call bash-json.parse 'package.json' It would follow that the I understand the link you send is a very quick prototype, but I'll mention that any It would be hard to provide some fallback for POSIX sh, since Bundling
I very much like the idea of bundling. Super useful if the user doesn't have some sort of Bash package manager installed, and needs to use the functionality. I haven't thought too hard about it lately, since I believe it would be wise to standardize entrypoints for packages/modules and certain variables Error reporting
Agreed - it is kind of tricky due to The first way is for quick scripts. On error, we terminate ( call bash-toml.parse 'file.sh'
# => Error: bash-toml.parse: Could not find file.sh The second way, is that on error, we return with a non-zero exit code, and set the stack trace in some variable (e.g. if call bash-toml.parse 'file.sh'; then :; else
printf '%s\n' "There appears to be an error with"
printf '%s' "$ERR"
fi
Like a linter to check for error reporting, correct module format, etc.
I like DocOpt in general, but for Bash, they do some weird Go codegen thing. I made a parser hyperupcall/bash-args that has similar functionality (but using an incompatible argument string spec) that supports a bit less features, but is very fast without a codegen step. I've been meaning to rewrite it to be compatible, but haven't gotten around to it I also think it would be wise to separate argument parsing into two categories: for functions and executables. Full-blown argument parsing can get quite expensive if we are using it for many function calls. DocOpt-style stuff is good for executables, but for functions having a super basic stripped down version would really benefit speed of execution data manipulation
Method-based data manipulation compared to somewhat vague features at the syntax level may be the way to go, especially for people newer to Bash. That is something a standard library can provide. As for arbitrarily nested structures, I made bash-object, which may be of use. I made it because I had to for my fully-bash JSON and TOML parsers. Package management
Agreed there would need to be some Basher-style package manager. Exiting projects like bats-assert and bats-support use a I actually forked
Agreed. It clobbers NPM's
Agreed. Right now bpm doesn't inherently support multi-package monorepos, but it can be done by just setting different globals. For example, I'm working on a bash standard library (that isn't public yet), and naming functions
bpm could be that "reference implementation". I think it would be wise to specify what exactly what we want it to do. For example, the way bpm currently handles per project, local dependencies should probably change. Right now bpm behaves a certain way, but I am definitely open to changing that, there is some stuff that definitely needs to be changed
Right now, with bpm, dependencies are Git cloned to
I think autoloading is a must. Something along the lines of the package manager providing a function that will read all of the
bpm automatically supports most standard Bash projects.
bpm supports Git repositories hosted on any website and arbitrary git ssh uris ExamplesExamples:
bpm add tj/git-extras
bpm add github.com/tj/git-extras
bpm add https://github.com/tj/git-extras
bpm add [email protected]:tj/git-extras
bpm add hyperupcall/bash-args --branch=main
bpm add hyperupcall/[email protected] # out of date
bpm supports specifying commits and tags after the package name
Yes, there will be support for multiple versions. This will be facilitated with the some I think a lot of the ideas mentioned here are important to get right as soon as possible, so we can update interfaces / iterate without worrying about a ton of breakage, at least until 1.0.0 RC's. If we can expose functionality with a modular library-approach rather than a framework approach, that would be good for composition and interoperability in the bash ecosystem as a whole. As far as bpm is concerned, I want to make sure we get the 'How will 3rd party libs be organized in a project?' question answered properly, and make cli usage as fluid as possible. For example right now |
Beta Was this translation helpful? Give feedback.
-
Bash is super easy language that glues things together in nice way. Only thing missing is proper data-structures support. If we want to get most milage from what is already in bash, framework should not affect regular script writing technique. Lets try not to reinvent PowerShell or Perl MVP: |
Beta Was this translation helpful? Give feedback.
-
Thanks for everyone's thoughts so far! @adudek @hyperupcall Since I'm rather tied up with other projects at the moment, I don't see myself working on 3.0 anytime soon. If any of you would like to give a POC/MVP a go, feel free to open a PR against the 3.0 branch, and we can all chime in with feedback/suggestions. I think we're mostly in agreement as to what's missing in bash, perhaps the scope of what each of us wants differs, but if we start with a good module+package system, it won't really matter - anyone should be able to either use as much or as little of the framework as they want. My suggestion for a module system is here, it's basically a simple implementation of node's CommonJS require. Granted, it's a little verbose in usage, cause you need to specify what module you're invoking from with every invocation, but I haven't found a way around it that wouldn't pollute the global scope. |
Beta Was this translation helpful? Give feedback.
-
Packages aren't published to a BPKG registry. You install packages in the format |
Beta Was this translation helpful? Give feedback.
-
Continuing from #44 (comment).
@tterranigma Let's discuss the scope of 3.0.
I've added you as a collaborator so you have push rights to the repo.
We should decide on the features to focus on implementing and problems needing tackling first. I've opened a clean branch (3.0) so we can work with a clean slate.
We can keep the outcome of the discussion as documentation inside of the repo itself, e.g. in a
docs
folder.Some things that come to mind while designing the future:
Module system
Any respecting language ecosystem has a module system for managing and sharing dependencies/libraries (JS has
npm
, Python hasPyPi
, Ruby hasRubyGem
, C# has NuGet, and so on). I think we should think about both a method of sharing internal and external "modules", which is especially difficult, since functions are global inbash
.For a non-polluting way of loading, I propose something in the lines of my experiment here.
For a shared repository of public (and private) libraries we could use GitHub, just as
Go
does it.Another useful feature that I thought about is would be "bundling", i.e. replacing and inlining all imports, in order, with actual code. This would be great for distributing, since you could use all the features you want and just move/upload a single script file that has all of the functionality embedded.
Features from 2.0
Which are the most important to port first?
Other ideas
bashdb
for debugging would be really useful.Thoughts?
Beta Was this translation helpful? Give feedback.
All reactions