≡ Menu

Bash return values

Debugging a Bash script today and ran into this problem – return/exit codes from functions may not exceed 255! My script backed up a subversion repository only when a new version of the repo existed, however, the function that checked the version had it’s output returned modulo 255, causing a problem.

The solution was to return the data with echo, as suggested here: http://tldp.org/LDP/abs/html/assortedtips.html#RVT

Then the call

curVersion=`check_version ${SUBVERSION_REPOSITORY} ${SUBVERSION_REPOSITORY_NAME}`

assigns the result from the function check_version to curVersion.


				
{ 0 comments… add one }

Leave a Comment