skarnet / execline Goto Github PK
View Code? Open in Web Editor NEWThe execline scripting language
Home Page: https://skarnet.org/software/execline/
License: ISC License
The execline scripting language
Home Page: https://skarnet.org/software/execline/
License: ISC License
I used to use a command-line utility called dmenu
, but came to like an alternative to it called fuzzel
that has the same input and output format but has slightly different options.
More specifically, dmenu
had a -x
option, but fuzzel
's equivalent is called --password
. -x
in fuzzel does something completely different.
In order not to rewrite all my scripts using dmenu
due to this small difference, I thought of making /usr/local/bin/dmenu
an execline wrapper:
#!/bin/execlineb
elgetopt ixl:p:
multisubstitute {
importas hide ELGETOPT_x
importas lines ELGETOPT_l
importas prompt ELGETOPT_p
}
emptyenv -c fuzzel -d --password$hide -l$lines -p$prompt
Here comes the problem. -l
and -p
work as intended (being omitted entirely if not given by the script), but when -x
is given, it comes out as --password1
which is an invalid option.
The only alternatives I'm seeing are either
backtick { ifelse { eltest } ... }
+ importas -s
ifthenelse
which shall not be documented.The solution I'm proposing is for 1
to be overrideable by the user. For instance, making elgetopt
insert an empty word into the environment instead of 1 would make my script work.
I've got some scripts which don't take any arguments (hence the -P), but I would like to know the name of the executing script which is normally set in 0 env. Also, -S0 is the same problem.
Here's my script:
#!/bin/execlineb
backtick -E scriptdir {
importas arg0 0
dirname "$arg0"
}
envfile "/etc/s6/sv/${scriptdir}/conf"
......
But I found that when I use the -P tag, no variables (including 0) are defined. I would expect in either case, 0 to contain the name of the script even when no variables are being passed in.
fdmove 1 1
is correctly a no-op, but fdmove -c
will fail if you use the same file descriptor:
$ fdmove 1 1 ls -l /proc/self/fd
total 0
lrwx------ 1 emanuele6 wheel 64 Nov 16 09:23 0 -> /dev/pts/7
lrwx------ 1 emanuele6 wheel 64 Nov 16 09:23 1 -> /dev/pts/7
lrwx------ 1 emanuele6 wheel 64 Nov 16 09:23 2 -> /dev/pts/7
lr-x------ 1 emanuele6 wheel 64 Nov 16 09:23 3 -> /proc/3330198/fd
$ fdmove -c 1 1 ls -l /proc/self/fd
fdmove: fatal: unable to move fd 1 to fd 1: Invalid argument
skalibs
's fd_copy(to, from)
function hardcodes to == from
as a failure instead of returning to
for successful no-op if it's positive, or just calling dup2(to, from)
and letting it do nothing successfully.
When you are doing something like fdmove -c 1 "$fd"
, the fact that it fails if fd
is 1 is unideal.
Slightly related: fdmove
is documented as
On a
fdmove a b prog...
is roughly equivalent tosh -c 'exec prog... a>&b b<&-'
. It means: if you write to fd a now, it will have the same effect as writing to fd b beforehand, and you cannot write to fd b anymore.
I think it could be useful to mention that fdmove a b
is not simply equivalent to fdmove -c a b fdclose b
, because it is a no-op and won't close b
if a == b
; more like a<&b-
in bash/ksh93 rather than a<&b b<&-
.
o/
emanuele6
Following the standard build-from-code process
RUN cd /tmp && git clone git://git.skarnet.org/execline && cd execline && ./configure && make && make install
In libskarnet.so we are receiving errors stating an undefined reference to timer_create, timer_delete, and timer_settime.
This appears related to the execline repo which is why I posted it here, but it seems like it could be related to the skarnet/skalibs repo / dependency as well.
Bash has job control functionality that lets you provide a set of pids and then exit when any one of them exits. I think this can be implemented with wait and using signal(SIGCHLD, SIG_IGN)
. As far as I know, since it's a builtin in bash and there's no other command to do this, currently if you have multiple background processes and need to wait on any of them to die, it's not possible with just execline.
Command substitutions in standard shells always set the special parameter ?
as a side-effect, so it is generally possible to retrieve the exit status of a command while capturing output. AFAICT the backtick
utility is just opaque and discards the status unconditionally.
The only practical workaround I know of currently is to replace backtick v { ... }
with an equivalent pipeline { ... } withstdinas v wait -o { }
. backtick
is certainly much more concise and reasonable for simple tasks so it would be very convenient if the status returned by its wait() were exposed through ?
.
Hi.
Statically linked binaries for execline costs 15 megabytes. It is a lot! Can you, please, provide a busybox-style binary for them?
reproduce:
backtick PWD { pwd }
importas MYPATH PWD
foreground
{ mkdir -p /logs${MYPATH} }
take a look at /logs
there is a ? in the path
It says in the documentation that the env and data dir are copied to the service directory.
So therefore I can use relative paths in my up/down/run scripts.
But it seems that the data dir is not copied for oneshot scripts, is this true or am I doing something wrong?
I found something in the mailing list about it, but it was just a passing reference, so wanted to clarify.
I would like to us execline in Fedora, and Fedora CoreOS attempting to install using: https://fedora.pkgs.org/31/rpm-sphere-x86_64/execline-devel-2.3.0.4-7.1.x86_64.rpm.html
error: Checkout execline-2.3.0.4-7.1.x86_64: Hardlinking 9c/8aa019367d3a8fa2545da722c3c4e2aabc9fd35c1e9a46cc33f1342f781454.file to cd: File exists
Would it be preferable to use an alternative path?
This is a wonderful tool! Is there a way to use execline without installing it in /bin or any dir in PATH? I initially thought that EXECLINE_BINPREFIX
can be used to launch execline progs with absolute path, but apparently this is partially true only. Right now, I am using a loader script to add the installation dir to PATH and then call execlineb, but that breaks if the loaded script modifies PATH.
Good day.
Is it possible to create a "variable" with a generated name and argument value, and then use this "variable" when calling a command?
I give a demo example, where I removed all unnecessary, leaving only the essence of the issue:
define password_file "/root/.vncpswd"
backtick !
{
ifelse { test -s "$password_file" }
{
echo "-rfbauth ${password_file}"
}
echo "-nopw"
}
importas -u password_arg !
/usr/bin/x11vnc $password_arg
If the file does not exist or is empty, there are no errors.
If the file exists and is not empty - error:
unrecognized option(s)
-rfbauth /root/.vncpswd
This is similar to the behavior in Shell if the variable is specified in double quotes:
/usr/bin/x11vnc "$password_arg"
I tried to build with the latest release and previous versions. It pops up different error issue. Could you provide a compatible version among skalibs && execline && s6? thanks
src/libexecline/el_modif_and_spawn.c: In function 'el_modif_and_spawn': src/libexecline/el_modif_and_spawn.c:24:3: error: implicit declaration of function 'env_mergen' [-Werror=implicit-function-declaration] if (!env_mergen(newenv, envlen + 2, (char const *const *)environ, envlen, value ? modifs : var, value ? modiflen : varlen + 1, 1)) return 0 ; ^ cc1: some warnings being treated as errors make: *** [Makefile:135: src/libexecline/el_modif_and_spawn.lo] Error 1
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.