X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/f2425e2fdede42a7ebd8e95a58d0f4f7bb4e9963..9c4b046a0b348663606b63e1446aba8c77cb2b1a:/tools/fix-paje-trace.sh diff --git a/tools/fix-paje-trace.sh b/tools/fix-paje-trace.sh index cb743ce069..e01e4d6aa3 100755 --- a/tools/fix-paje-trace.sh +++ b/tools/fix-paje-trace.sh @@ -1,4 +1,9 @@ -#!/bin/bash +#!/usr/bin/env bash + +# 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. if [ -z $1 ] then @@ -8,24 +13,22 @@ fi TRACE=$1 echo "input: $TRACE" -OUTPUT=`echo $TRACE | cut -d\. -f1`.fix.trace +OUTPUT=${TRACE%.*}.fix.trace -cat $TRACE | grep ^% > header -DEFEVENTS=`cat header | grep Define | 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; /^%E/d; $GREP" +GREP2=( -e $'^%[ \tE]' "${GREP[@]}" ) -cat $TRACE | eval grep $GREP2 > types -/bin/sed -e "$GREP" $TRACE > events -cat events | sort -n -k 2 -s > events.sorted -cat header types events.sorted > $OUTPUT -rm types events events.sorted header +grep "${GREP[@]}" -- "$TRACE" > types +grep -v "${GREP2[@]}" -- "$TRACE" > events +sort -n -k 2 -s < events > events.sorted +cat header types events.sorted > "$OUTPUT" +rm -f types events events.sorted header echo "output: $OUTPUT"