Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
6
66
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Eric Vidal
66
Commits
7a1aacdd
Commit
7a1aacdd
authored
6 years ago
by
Eric Vidal
Browse files
Options
Downloads
Patches
Plain Diff
execl-cmdline: add -s features
parent
b92bda30
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/66/execl-cmdline.c
+53
-10
53 additions, 10 deletions
src/66/execl-cmdline.c
with
53 additions
and
10 deletions
src/66/execl-cmdline.c
+
53
−
10
View file @
7a1aacdd
...
...
@@ -12,42 +12,85 @@
* except according to the terms contained in the LICENSE file./
*/
#include
<oblibs/string.h>
#include
<oblibs/stralist.h>
#include
<oblibs/error2.h>
#include
<skalibs/stralloc.h>
#include
<skalibs/
strerr2
.h>
#include
<skalibs/
genalloc
.h>
#include
<skalibs/env.h>
#include
<skalibs/djbunix.h>
#include
<skalibs/sgetopt.h>
#include
<execline/execline.h>
#define USAGE "execl-cmdline [ -s ] { command... }"
int
main
(
int
argc
,
char
const
**
argv
,
char
const
*
const
*
envp
)
{
int
r
,
argc1
;
int
r
,
argc1
,
split
;
PROG
=
"execl-cmdline"
;
stralloc
tmodifs
=
STRALLOC_ZERO
;
stralloc
modifs
=
STRALLOC_ZERO
;
genalloc
ga
=
GENALLOC_ZERO
;
r
=
0
;
r
=
argc1
=
split
=
0
;
argc1
=
el_semicolon
(
++
argv
)
;
if
(
argc1
>=
--
argc
)
strerr_dief1x
(
100
,
"unterminated block"
)
;
{
subgetopt_t
l
=
SUBGETOPT_ZERO
;
for
(;;)
{
int
opt
=
subgetopt_r
(
argc
,
argv
,
"s"
,
&
l
)
;
if
(
opt
==
-
1
)
break
;
switch
(
opt
)
{
case
's'
:
split
=
1
;
break
;
default
:
exitusage
()
;
}
}
argc
-=
l
.
ind
;
argv
+=
l
.
ind
;
}
argc1
=
el_semicolon
(
argv
)
;
if
(
argc1
>=
argc
)
strerr_dief1x
(
100
,
"unterminated block"
)
;
argv
[
argc1
]
=
0
;
char
const
**
newargv
=
argv
;
for
(
int
i
=
0
;
i
<
argc1
;
i
++
,
newargv
++
)
for
(
int
i
=
0
;
i
<
argc1
;
i
++
,
newargv
++
)
{
if
(
!*
newargv
[
0
])
continue
;
stralloc_cats
(
&
modifs
,
*
newargv
)
;
stralloc_0
(
&
modifs
)
;
if
(
!
stralloc_cats
(
&
tmodifs
,
*
newargv
))
retstralloc
(
111
,
"tmodifs"
)
;
if
(
split
)
{
if
(
!
stralloc_cats
(
&
tmodifs
,
" "
))
retstralloc
(
111
,
"tmodifs"
)
;
}
else
if
(
!
stralloc_0
(
&
tmodifs
))
retstralloc
(
111
,
"tmodifs_0"
)
;
r
++
;
}
if
(
split
)
{
if
(
!
clean_val
(
&
ga
,
tmodifs
.
s
))
strerr_diefu2x
(
111
,
"clean val: "
,
tmodifs
.
s
)
;
for
(
unsigned
int
i
=
0
;
i
<
genalloc_len
(
stralist
,
&
ga
)
;
i
++
)
{
stralloc_cats
(
&
modifs
,
gaistr
(
&
ga
,
i
))
;
stralloc_0
(
&
modifs
)
;
}
r
=
genalloc_len
(
stralist
,
&
ga
)
;
genalloc_deepfree
(
stralist
,
&
ga
,
stra_free
)
;
}
else
if
(
!
stralloc_copy
(
&
modifs
,
&
tmodifs
))
retstralloc
(
111
,
"copy"
)
;
stralloc_free
(
&
tmodifs
)
;
char
const
*
newarg
[
r
+
1
]
;
if
(
!
env_make
(
newarg
,
r
,
modifs
.
s
,
modifs
.
len
))
strerr_diefu1sys
(
111
,
"env_make"
)
;
newarg
[
r
]
=
0
;
xpathexec_run
(
newarg
[
0
],
newarg
,
envp
)
;
//el_execsequence(newarg, argv+argc1+1, envp) ;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment