Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ShellB3
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Ray Garcia
ShellB3
Commits
bd764928
Commit
bd764928
authored
8 years ago
by
Joe Garcia
Browse files
Options
Downloads
Patches
Plain Diff
re-l documentation!
parent
452975ad
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ShellB3/sbin/re-l
+17
-3
17 additions, 3 deletions
ShellB3/sbin/re-l
with
17 additions
and
3 deletions
ShellB3/sbin/re-l
+
17
−
3
View file @
bd764928
...
@@ -51,9 +51,11 @@ def getLine(f,linenumber=1):#returns native string (ascii or unicode)
...
@@ -51,9 +51,11 @@ def getLine(f,linenumber=1):#returns native string (ascii or unicode)
v
=
''
v
=
''
return
v
return
v
#deterimine if the script is a single-parameter env-based script file
def
isRelScript
(
filepath
):
def
isRelScript
(
filepath
):
return
getLine
(
filepath
,
linenumber
=
1
)
==
'
#!/usr/bin/env re-l
'
return
getLine
(
filepath
,
linenumber
=
1
)
==
'
#!/usr/bin/env re-l
'
#extract the interpreter from a scriptfile
def
extractRelInterpreter
(
filepath
):
def
extractRelInterpreter
(
filepath
):
if
not
isRelScript
(
filepath
):
if
not
isRelScript
(
filepath
):
raise
RuntimeError
(
"
Not a re-l script!
"
)
raise
RuntimeError
(
"
Not a re-l script!
"
)
...
@@ -63,11 +65,12 @@ def extractRelInterpreter(filepath):
...
@@ -63,11 +65,12 @@ def extractRelInterpreter(filepath):
return
l
.
split
(
'
:
'
,
1
)[
1
].
strip
()
return
l
.
split
(
'
:
'
,
1
)[
1
].
strip
()
raise
RuntimeError
(
"
Couldn
'
t find re-lative interpreter line (starts with
'
#re-l:
'
)
"
)
raise
RuntimeError
(
"
Couldn
'
t find re-lative interpreter line (starts with
'
#re-l:
'
)
"
)
def
relexec
(
interpreter
,
scriptfile
,
*
_args
):
#executes a scriptfile using a relative interpreter with given commandline args
def
relexec
(
scriptrelativeinterpreter
,
scriptfile
,
*
_args
):
args
=
[
None
,
None
]
+
list
(
_args
)
args
=
[
None
,
None
]
+
list
(
_args
)
LOG
(
'
%s %s
'
%
(
interpreter
,
scriptfile
))
LOG
(
'
%s %s
'
%
(
scriptrelative
interpreter
,
scriptfile
))
scriptpath
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
scriptfile
))
scriptpath
=
os
.
path
.
dirname
(
os
.
path
.
realpath
(
scriptfile
))
interpreter
=
os
.
path
.
normpath
(
os
.
path
.
join
(
scriptpath
,
interpreter
))
interpreter
=
os
.
path
.
normpath
(
os
.
path
.
join
(
scriptpath
,
scriptrelative
interpreter
))
LOG
(
'
%s %s
'
%
(
scriptpath
,
interpreter
))
LOG
(
'
%s %s
'
%
(
scriptpath
,
interpreter
))
args
[
0
]
=
interpreter
args
[
0
]
=
interpreter
args
[
1
]
=
scriptfile
args
[
1
]
=
scriptfile
...
@@ -84,6 +87,17 @@ def relexec(interpreter,scriptfile,*_args):
...
@@ -84,6 +87,17 @@ def relexec(interpreter,scriptfile,*_args):
raise
RuntimeError
(
'
Exec Failed
'
)
raise
RuntimeError
(
'
Exec Failed
'
)
def
main
():
def
main
():
if
len
(
sys
.
argv
)
<
2
or
(
len
(
sys
.
argv
)
<
3
and
not
isRelScript
(
sys
.
argv
[
1
])):
print
(
'
re-l relative interpreter proxy script
'
)
print
(
'
Usage: with re-l anywhere in the path modify any script shebang to be:
'
)
if
'
darwin
'
in
sys
.
platform
:
print
(
'
\t
#!/usr/bin/env re-l relative/path/to/interpeter
'
)
else
:
print
(
'
\t
#!/usr/bin/env re-l
'
)
print
(
'
and then for the second or third line, add the line:
'
)
print
(
'
\t
#re-l:relative/path/to/interpeter
'
)
print
(
'
where the interpreter is identified relative to the script file itself
'
)
sys
.
exit
(
0
)
if
len
(
sys
.
argv
)
==
2
or
isRelScript
(
sys
.
argv
[
1
]):
if
len
(
sys
.
argv
)
==
2
or
isRelScript
(
sys
.
argv
[
1
]):
assert
(
isRelScript
(
sys
.
argv
[
1
]))
assert
(
isRelScript
(
sys
.
argv
[
1
]))
relexec
(
extractRelInterpreter
(
sys
.
argv
[
1
]),
sys
.
argv
[
1
],
*
sys
.
argv
[
2
:])
relexec
(
extractRelInterpreter
(
sys
.
argv
[
1
]),
sys
.
argv
[
1
],
*
sys
.
argv
[
2
:])
...
...
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