Coder Social home page Coder Social logo

execline's People

Contributors

heliocat avatar mobin-2008 avatar skarnet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

execline's Issues

Overriding "1" as elgetopt's default substitution

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
  • the option for 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.

#!/bin/execlineb -P doesn't set $0

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 -c 1 1 cmd` fails

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.

https://github.com/skarnet/skalibs/blob/2ea36ebf726bb3a29ff8c6b12a6ff3df9020859f/src/libstddjb/fd_copy.c#L10

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 to sh -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

Failing to build

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.

Wait on any process

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.

`backtick` doesn't set `?`

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 ?.

Busybox-style build

Hi.

Statically linked binaries for execline costs 15 megabytes. It is a lot! Can you, please, provide a busybox-style binary for them?

importas bug

reproduce:
backtick PWD { pwd }
importas MYPATH PWD
foreground
{ mkdir -p /logs${MYPATH} }
take a look at /logs
there is a ? in the path

data dir copied for oneshot scripts?

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.

must rely on 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.

Argument Generation

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"

failed to build

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.