X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/abc086c715d231160badf9078368d190e47a9028..d2182f07ffae5d26030b8f05cb2f3eb845c5bb4d:/tools/fix-paje-trace.sh diff --git a/tools/fix-paje-trace.sh b/tools/fix-paje-trace.sh index 0d854900f5..e01e4d6aa3 100755 --- a/tools/fix-paje-trace.sh +++ b/tools/fix-paje-trace.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Copyright (c) 2010-2017. The SimGrid Team. All rights reserved. +# Copyright (c) 2010-2020. The SimGrid Team. All rights reserved. # This program is free software; you can redistribute it and/or modify it # under the terms of the license (GNU LGPL) which comes with this package. @@ -13,24 +13,22 @@ fi TRACE=$1 echo "input: $TRACE" -OUTPUT=$( echo $TRACE | cut -d\. -f1 ).fix.trace +OUTPUT=${TRACE%.*}.fix.trace -grep ^% < $TRACE > header -DEFEVENTS=$(grep Define < header | awk '{ print $3 }') +grep ^% -- "$TRACE" > header +DEFEVENTS=( $(awk '/Define/ { print $3 }' header) ) -GREP="" -GREP2="" -for i in $DEFEVENTS +GREP=() +for i in "${DEFEVENTS[@]}" do - GREP="/^$i /d; $GREP" - GREP2="-e '^$i ' $GREP2" + GREP+=( -e "^$i " ) done -GREP="/^%\ /d; /^% /d; /^%E/d; $GREP" +GREP2=( -e $'^%[ \tE]' "${GREP[@]}" ) -grep $GREP2 < $TRACE > types -/bin/sed -e "$GREP" $TRACE > events +grep "${GREP[@]}" -- "$TRACE" > types +grep -v "${GREP2[@]}" -- "$TRACE" > events sort -n -k 2 -s < events > events.sorted -cat header types events.sorted > $OUTPUT -rm types events events.sorted header +cat header types events.sorted > "$OUTPUT" +rm -f types events events.sorted header echo "output: $OUTPUT"