monitors/oftraf/clean.sh
#!/bin/bash # Copyright (c) 2015 Intracom S.A. Telecom Solutions. All rights reserved.## This program and the accompanying materials are made available under the# terms of the Eclipse Public License v1.0 which accompanies this distribution,# and is available at http://www.eclipse.org/legal/epl-v10.html SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)Double quote to prevent globbing and word splitting.echo $SCRIPT_DIR Iterating over ls output is fragile. Use globs.
Double quote to prevent globbing and word splitting.for item in $( ls -1 $SCRIPT_DIR ); doDouble quote to prevent globbing and word splitting. if [ $item != 'build.sh' ] && [ $item != 'clean.sh' ]; thenDouble quote to prevent globbing and word splitting.
Use "${var:?}" to ensure this never expands to / . rm -rf $SCRIPT_DIR/$itemCheck exit code directly with e.g. 'if mycmd;', not indirectly with $?. if [ $? -ne 0 ]; then echo "[clean.sh] Cleanup of oftraf failed. Exiting ..." exit $? fi fidone echo "[clean.sh] Cleanup of oftraf completed successfully"