10
0
mirror of https://github.com/LCPQ/quantum_package synced 2024-11-19 04:22:36 +01:00
quantum_package/scripts/qp_include.sh
2015-05-04 15:03:53 +02:00

82 lines
1.2 KiB
Bash

#!/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()
{
if [[ "${PWD}" == "${QPACKAGE_ROOT}/src" ]]
then
return 0
else
echo "Current directory should be \$QPACKAGE_ROOT/src"
exit -1
fi
}
function check_current_dir_is_module()
{
cd ..
if [[ "${PWD}" == "${QPACKAGE_ROOT}/src" ]]
then
cd $OLDPWD
return 0
else
cd $OLDPWD
echo "Current directory should be \$QPACKAGE_ROOT/src"
exit -1
fi
}
if [[ -f NEEDED_CHILDREN_MODULES ]]
then
NEEDED_MODULES=$(module_handler.py print_genealogy NEEDED_CHILDREN_MODULES)
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