I've run into a couple of issues with the scripts provided by the "ccm-devel" RPM. When executing |$ ccm-profile ccm60 I get |/etc/ccm-devel/project5x.sh: line 5: return: can only `return' from a function or sourced script |/etc/ccm-devel/project5x.sh: line 206: `ccm-inst': not a valid identifier |bash: tempenv.sh: line 1: syntax error near unexpected token `newline' |bash: tempenv.sh: line 1: `ccm-devel-profile.sh <servername>' The first error is due to the fact that "return" is used outside of a function body, as in the following example: |$ p4 print //tools/ccmbuild/devel/dev/etc/project5x.sh#2 | \ | grep -vE '^//tools' | head -n 5 | tail -n 3 |if [ "x$1" = "x" ] ; then | echo "ccm-devel-profile.sh <servername>" | return This generates a warning and the script continues to execute. The intent seems to have been to call "exit 0" or "exit 1" or some such instead. There is more than one place where "return" is used in this way. |$ rpm -qf /etc/ccm-devel/project5x.sh |ccm-devel-2.0.0.AUTO.41241-5 The second error is that bash doesn't like the '-' in the function name. ccm-inst is the first occurrence of such a name in /etc/ccm-devel/project5x.sh: |$ cat -n /etc/ccm-devel/project5x.sh | head -n 206 | tail -n 7 | 200 function ccm-inst() { | 201 ( | 202 cddev; | 203 ant clean; | 204 ant deploy | 205 ) | 206 } The error with tempenv.sh happens because the earlier use of "return" fails to abort the script execution, and tempenv.sh ends up looking like so: |$ cat /tempenv.saved |ccm-devel-profile.sh <servername> |Warning: Cannot find postgres jdbc2 library |Looked for: /usr/share/pgsql/java/rh-pgsql-jdbc2.jar /usr/share/pgsql/jdbc7.2dev-1.2.jar /usr/share/pgsql/pg73b1jdbc2.jar |Point PG_JDBC2_LIB to correct location if using PostgreSQL The tempenv.sh thingy is also a source of infrequent errors of the following kind: |$ ccm-profile ccm60 |bash: tempenv.sh: Permission denied This happens when you run the ccm-profile command from a directory in which you don't have write permissions, such as /usr/bin. This happens because the /usr/bin/ccm-devel-profile.sh script tries to create a temporary file named tempenv.sh in the current directory. If you don't have write permissions for the current directory, you're screwed: $ cat -n /usr/bin/ccm-devel-profile.sh | head -n 19 | tail -n 4 16 perl $CCM_DEVEL_CONF_DIR/project.pl $@ > tempenv.sh 17 if [ $? != 0 ]; then 18 return 19 fi $ rpm -qf /usr/bin/ccm-devel-profile.sh ccm-devel-2.0.0.AUTO.41241-5
The first issue listed (about using return) was fixed @41473. Looking at the rest now...
As of @41277, ccm-devel-profile.sh uses a temp file instead if ./tempenv.sh, so you can run ccm-profile from anywhere.