10
0
mirror of https://github.com/LCPQ/quantum_package synced 2024-11-09 07:33:53 +01:00
quantum_package/scripts/qp_include.sh

79 lines
1.3 KiB
Bash
Raw Normal View History

#!/bin/bash
#
# Useful functions in all scripts
# Make a list unique
function unique_list()
{
for d in $@
do
echo $d
done | sort | uniq
}
function check_current_dir_is_src()
{
2015-06-08 14:49:10 +02:00
if [[ "${PWD}" == "${QP_ROOT}/src" ]]
then
return 0
else
2015-06-08 14:49:10 +02:00
echo "Current directory should be \$QP_ROOT/src"
exit -1
fi
}
function check_current_dir_is_module()
{
2015-06-08 14:49:10 +02:00
# If the prefix ${QP_ROOT}/src/ can be removed from $PWD, it means that
# $PWD is somewhere below ${QP_ROOT}/src/ so it is a module.
# If the prefix ${QP_ROOT}/src/ can not be removed from $PWD, then
# "${PWD##${QP_ROOT}/src/}" == "$PWD".
2015-05-15 16:30:43 +02:00
2015-06-08 14:49:10 +02:00
if [[ "${PWD##${QP_ROOT}/src/}" != "$PWD" ]]
then
return 0
else
2015-05-15 16:30:43 +02:00
echo "You are not in a submodule"
exit -1
fi
}
# List of executables in the current directory
function ls_exe()
{
find . -perm /u+x -type f
}
function asksure() {
echo -n $@ "(Y/N) "
answer=w
while [[ $answer != [YyNn] ]]
do
read answer
[[ $answer = [Yy] ]] && retval=0 || retval=1
done
return $retval
}
function error()
{
echo "-------------------- Error --------------------"
printf "$@\n"
echo "-----------------------------------------------"
exit -1
}
if [[ -z ${DEBUG} ]]
then
function info ()
{
:
}
else
function info ()
{
echo "$@"
}
fi