Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
eepm
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
eepm
Commits
4fd36a12
Commit
4fd36a12
authored
Apr 03, 2023
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add compatibility layer (print_command_path, is_command, subst) to pack.d and repack.d
parent
a163769a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
73 additions
and
4 deletions
+73
-4
common.sh
pack.d/common.sh
+42
-2
common.sh
repack.d/common.sh
+31
-2
No files found.
pack.d/common.sh
View file @
4fd36a12
...
@@ -6,9 +6,39 @@ fatal()
...
@@ -6,9 +6,39 @@ fatal()
exit
1
exit
1
}
}
# compatibility layer
# print a path to the command if exists in $PATH
if
which which 2>/dev/null
>
/dev/null
;
then
# the best case if we have which command (other ways needs checking)
# TODO: don't use which at all, it is binary, not builtin shell command
print_command_path
()
{
which
--
"
$1
"
2>/dev/null
}
elif
type
-a
type
2>/dev/null
>
/dev/null
;
then
print_command_path
()
{
type
-fpP
--
"
$1
"
2>/dev/null
}
else
print_command_path
()
{
type
"
$1
"
2>/dev/null |
sed
-e
's|.* /|/|'
}
fi
# check if <arg> is a real command
is_command
()
{
print_command_path
"
$1
"
>
/dev/null
}
# compatibility layer
# compatibility layer
# add realpath if missed
# add realpath if missed
if
!
which
realpath
2>/dev/null
>
/dev/null
;
then
if
!
is_command
realpath
;
then
realpath
()
realpath
()
{
{
[
-n
"
$*
"
]
||
return
[
-n
"
$*
"
]
||
return
...
@@ -17,13 +47,15 @@ realpath()
...
@@ -17,13 +47,15 @@ realpath()
fi
fi
# add subst if missed
# add subst if missed
if
!
which subst 2>/dev/null
>
/dev/null
;
then
if
!
is_command subst
;
then
subst
()
subst
()
{
{
sed
-i
-e
"
$@
"
sed
-i
-e
"
$@
"
}
}
fi
fi
erc
()
erc
()
{
{
epm tool erc
"
$@
"
epm tool erc
"
$@
"
...
@@ -34,6 +66,14 @@ is_dir_empty()
...
@@ -34,6 +66,14 @@ is_dir_empty()
[
-z
"
$(
ls
-A
"
$1
"
)
"
]
[
-z
"
$(
ls
-A
"
$1
"
)
"
]
}
}
# copied from strings
# CHECKME: the same like estrlist has ?
# Note: used grep -E! write '[0-9]+(first|two)', not '[0-9]\+...'
rhas
()
{
echo
"
$1
"
|
grep
-E
-q
--
"
$2
"
}
has_space
()
has_space
()
{
{
[
"
${
1
/ /
}
"
!=
"
$1
"
]
[
"
${
1
/ /
}
"
!=
"
$1
"
]
...
...
repack.d/common.sh
View file @
4fd36a12
...
@@ -7,8 +7,36 @@ fatal()
...
@@ -7,8 +7,36 @@ fatal()
}
}
# compatibility layer
# compatibility layer
# print a path to the command if exists in $PATH
if
which which 2>/dev/null
>
/dev/null
;
then
# the best case if we have which command (other ways needs checking)
# TODO: don't use which at all, it is binary, not builtin shell command
print_command_path
()
{
which
--
"
$1
"
2>/dev/null
}
elif
type
-a
type
2>/dev/null
>
/dev/null
;
then
print_command_path
()
{
type
-fpP
--
"
$1
"
2>/dev/null
}
else
print_command_path
()
{
type
"
$1
"
2>/dev/null |
sed
-e
's|.* /|/|'
}
fi
# check if <arg> is a real command
is_command
()
{
print_command_path
"
$1
"
>
/dev/null
}
# compatibility layer
# add realpath if missed
# add realpath if missed
if
!
which
realpath
2>/dev/null
>
/dev/null
;
then
if
!
is_command
realpath
;
then
realpath
()
realpath
()
{
{
[
-n
"
$*
"
]
||
return
[
-n
"
$*
"
]
||
return
...
@@ -17,13 +45,14 @@ realpath()
...
@@ -17,13 +45,14 @@ realpath()
fi
fi
# add subst if missed
# add subst if missed
if
!
which subst 2>/dev/null
>
/dev/null
;
then
if
!
is_command subst
;
then
subst
()
subst
()
{
{
sed
-i
-e
"
$@
"
sed
-i
-e
"
$@
"
}
}
fi
fi
# Remove file from the file system and from spec
# Remove file from the file system and from spec
# Usage: remove_file <path_to_file>
# Usage: remove_file <path_to_file>
remove_file
()
remove_file
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment