From: Sebastian Gniazdowski <psprint@zdharma.org>
To: Zsh Users <zsh-users@zsh.org>
Subject: Feature request: a command launcher
Date: Mon, 18 Dec 2017 10:39:33 +0100 [thread overview]
Message-ID: <etPan.5a378cd5.756ab874.19e@zdharma.org> (raw)
Hello
I came up with a feature that could be called "services". It's about defining a widely understood environment for a specified command. The point is that "environment" doesn't only mean: exported variables, but also: redirections, working directory, use of sudo, command arguments, etc. Present solutions like direnv/direnv handle only environment variables.
A definition of service could look like this:
#
# Definition of a service that builds Zsh located at
# ~/github/sfzsh3, with -O2 and pointers to libgdbm.
#
# This file is for configure script. File sfzsh3make
# is for running make, and is triggered automatically
# by this file
#
integer disabled=0
local command="./configure"
local arguments='--enable-unicode9'
integer spawn_type=0 # available: disown, fork, subshell, coproc, zpty, nohup;
# can combine to some extent, e.g. $(( fork | disown ))
integer run_method=command # available: command, autofun, source
local stdin="" # no redirection
local stdout="/dev/null"
local stderr=""
integer sudo=0
local run_first="" # no service to run first
local run_last="sfzsh3make" # run sfzsh3make after this service
local workdir="$HOME/github/sfzsh3"
integer cd=1 # stay in $workdir after this service finishes
local -A env
env=(
CFLAGS "-g -Wall -O2"
CPPFLAGS "-I/usr/local/include"
LDFLAGS "-L/usr/local/lib"
)
Then, to compile Zsh, one would issue: zsrv build_sfzsh3. "zsrv" is hard to type, the name should be better.
Someone might ask: why not create a script that holds complete configure command and make invocation. So why e.g. OS X does the definition-way for its services, it could just create and collect scripts ;) I'll limit to just this: the definition is just a series of parameter assignments, it's like separating data from presentation (XML vs. HTML). All this is a subtle, but still a paradigm-shift.
I'm worried about how many use cases would this have. Above "Zsh building that doesn't need history-dig, cd and parsing 'is it -O0 or -O2, what did I run last time'" is a good use case. But are there more use cases, has someone ideas?
I came up with this idea for Zplugin, but decided to ask in feature-request style, because I really think that Zsh would gain from such feature. And I'm curious of possible code and alterations. But I also need feedback if this looks useful or not.
--
Sebastian Gniazdowski
psprint /at/ zdharma.org
next reply other threads:[~2017-12-18 9:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-18 9:39 Sebastian Gniazdowski [this message]
2017-12-18 14:57 ` Sebastian Gniazdowski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=etPan.5a378cd5.756ab874.19e@zdharma.org \
--to=psprint@zdharma.org \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).