Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Z
zmap
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ensembl-gh-mirror
zmap
Commits
d97e37ae
Commit
d97e37ae
authored
17 years ago
by
zmap
Browse files
Options
Downloads
Patches
Plain Diff
shell script functions
parent
596a2569
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
scripts/zmap_functions.sh
+106
-0
106 additions, 0 deletions
scripts/zmap_functions.sh
with
106 additions
and
0 deletions
scripts/zmap_functions.sh
0 → 100755
+
106
−
0
View file @
d97e37ae
#!/bin/echo DOT SCRIPT please source
# A few absolute requirements for non-failure
if
[
"x
$SCRIPT_NAME
"
==
"x"
]
;
then
SCRIPT_NAME
=
$(
basename
$0
)
fi
if
[
"x
$ECHO
"
==
"x"
]
;
then
ECHO
=
/bin/echo
fi
# message functions
# Usage: zmap_message_out Your Message
function
zmap_message_out
{
now
=
$(
date
+%H:%M:%S
)
$ECHO
"[
$SCRIPT_NAME
(
$now
)]
$*
"
}
# Usage: zmap_message_err Your Message
function
zmap_message_err
{
now
=
$(
date
+%H:%M:%S
)
$ECHO
"[
$SCRIPT_NAME
(
$now
)]
$*
"
>
&2
}
# Usage: zmap_message_exit Your Message
function
zmap_message_exit
{
zmap_message_err
$*
exit
1
;
}
function
zmap_message_file
{
if
[
"x"
!=
"x
$1
"
]
;
then
local
file
=
$1
shift
$ECHO
"[
$SCRIPT_NAME
(
$now
)]
$*
"
>>
$file
fi
}
function
zmap_create_file
{
if
[
"x"
!=
"x
$1
"
]
;
then
$ECHO
-n
""
>
$1
fi
}
# last absolute requirements
if
[
"x
$BASE_DIR
"
==
"x"
]
;
then
zmap_message_exit
"
$0
needs to set BASE_DIR!"
fi
function
zmap_check
{
$ECHO
>
/dev/null
}
# common variables
ZMAP_TRUE
=
yes
ZMAP_FALSE
=
no
# default assignments...
zmap_check
${
RM
:
=rm
}
zmap_check
${
MKDIR
:
=mkdir
}
# common functions
# Usage: zmap_cd <dir>
function
zmap_cd
{
if
[
"x
$SILENT_CD
"
!=
"x
$ZMAP_TRUE
"
]
;
then
zmap_message_out
"cd
$1
"
fi
cd
$1
||
zmap_message_exit
"Failed to cd to
$1
"
}
function
zmap_mkdir
{
$MKDIR
-p
$1
||
zmap_message_exit
"Failed to mkdir
$1
"
}
function
zmap_clean_dir
{
if
[
-d
$1
]
;
then
save_dir
=
$(
pwd
)
zmap_cd
$1
zmap_message_out
"Running
$RM
-rf ./*"
$RM
-rf
./
*
||
zmap_message_exit
"Failed to remove files in
$1
"
zmap_cd
$save_dir
fi
}
# Usage: zmap_trap_handle
function
zmap_trap_handle
{
zmap_message_exit
"Signal caught!"
;
}
trap
'zmap_trap_handle;'
INT
trap
'zmap_trap_handle;'
TERM
trap
'zmap_trap_handle;'
QUIT
This diff is collapsed.
Click to expand it.
Preview
0%
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