Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Corryvreckan
Corryvreckan
Commits
c18c8b2f
Commit
c18c8b2f
authored
Nov 02, 2017
by
Daniel Hynds
Browse files
updated script for adding new algorithms
parent
cda83f76
Changes
1
Hide whitespace changes
Inline
Side-by-side
macros/addAlgorithm.sh
View file @
c18c8b2f
#!/bin/bash
# Check that only one argument was given
ARGS
=
1
if
[
$#
-ne
"
$ARGS
"
]
then
echo
"Please enter the new algorithm name"
exit
fi
# Ask for the name of the new algorithm
read
-p
"Name of the new algorithm: "
NEWALGORITHM
# Copy the GenericAlgorithm and replace the name with the new algorithm name
NEWALGORITHM
=
$1
cp
../algorithms/GenericAlgorithm.C ../algorithms/
${
NEWALGORITHM
}
.C
cp
../algorithms/GenericAlgorithm.h ../algorithms/
${
NEWALGORITHM
}
.h
# If running on mac, use this sed command
sed
-i
""
s/
"GenericAlgorithm"
/
"
${
NEWALGORITHM
}
"
/g ../algorithms/
${
NEWALGORITHM
}
.C
sed
-i
""
s/
"GenericAlgorithm"
/
"
${
NEWALGORITHM
}
"
/g ../algorithms/
${
NEWALGORITHM
}
.h
# If running on linux, use this command
#sed -i s/"GenericAlgorithm"/"${NEWALGORITHM}"/g ../algorithms/${NEWALGORITHM}.C
#sed -i s/"GenericAlgorithm"/"${NEWALGORITHM}"/g ../algorithms/${NEWALGORITHM}.C
echo
"Creating
${
NEWALGORITHM
}
.cpp"
cp
../src/algorithms/GenericAlgorithm.cpp ../src/algorithms/
${
NEWALGORITHM
}
.cpp
echo
"Creating
${
NEWALGORITHM
}
.h"
cp
../src/algorithms/GenericAlgorithm.h ../src/algorithms/
${
NEWALGORITHM
}
.h
# Check mac or linux platform
platform
=
`
uname
`
if
[
"
$platform
"
==
"Darwin"
]
then
sed
-i
""
s/
"GenericAlgorithm"
/
"
${
NEWALGORITHM
}
"
/g ../src/algorithms/
${
NEWALGORITHM
}
.cpp
sed
-i
""
s/
"GenericAlgorithm"
/
"
${
NEWALGORITHM
}
"
/g ../src/algorithms/
${
NEWALGORITHM
}
.h
else
sed
-i
s/
"GenericAlgorithm"
/
"
${
NEWALGORITHM
}
"
/g ../src/algorithms/
${
NEWALGORITHM
}
.cpp
sed
-i
s/
"GenericAlgorithm"
/
"
${
NEWALGORITHM
}
"
/g ../src/algorithms/
${
NEWALGORITHM
}
.h
fi
Write
Preview
Supports
Markdown
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!
Cancel
Please
register
or
sign in
to comment