X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/7fd8e8ffb447edb19f32e3200a7dbef3d83138b6..67a6dd7017d05c127cb0e6c2e2cb916c8e24f3f1:/examples/smpi/replay_multiple/generate_multiple_deployment.sh
diff --git a/examples/smpi/replay_multiple/generate_multiple_deployment.sh b/examples/smpi/replay_multiple/generate_multiple_deployment.sh
index c1272abb1a..ded0495928 100755
--- a/examples/smpi/replay_multiple/generate_multiple_deployment.sh
+++ b/examples/smpi/replay_multiple/generate_multiple_deployment.sh
@@ -1,6 +1,6 @@
#!/usr/bin/env sh
-# Copyright (c) 2007-2018. The SimGrid Team. All rights reserved.
+# Copyright (c) 2007-2022. 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.
@@ -65,7 +65,7 @@ while [ $# -gt 0 ]; do
;;
*)
PROC_ARGS="${PROC_ARGS:+$PROC_ARGS }$1"
- shift
+ shift
;;
esac
done
@@ -80,51 +80,51 @@ HOSTFILETMP=0
if [ -z "${HOSTFILE}" ] ; then
HOSTFILETMP=1
HOSTFILE="$(mktemp tmphostXXXXXX)"
- perl -ne 'print "$1\n" if /.*.*/' ${PLATFORM} > ${HOSTFILE}
+ perl -ne 'print "$1\n" if /.*.*/' "${PLATFORM}" > "${HOSTFILE}"
fi
UNROLLEDHOSTFILETMP=0
#parse if our lines are terminated by :num_process
-multiple_processes=$(grep -c ":" $HOSTFILE)
+multiple_processes=$(grep -c ":" "$HOSTFILE")
if [ "${multiple_processes}" -gt 0 ] ; then
UNROLLEDHOSTFILETMP=1
UNROLLEDHOSTFILE="$(mktemp tmphostXXXXXX)"
- perl -ne ' do{ for ( 1 .. $2 ) { print "$1\n" } } if /(.*?):(\d+).*/' ${HOSTFILE} > ${UNROLLEDHOSTFILE}
+ perl -ne ' do{ for ( 1 .. $2 ) { print "$1\n" } } if /(.*?):(\d+).*/' "${HOSTFILE}" > "${UNROLLEDHOSTFILE}"
if [ ${HOSTFILETMP} = 1 ] ; then
- rm ${HOSTFILE}
+ rm "${HOSTFILE}"
HOSTFILETMP=0
fi
HOSTFILE=$UNROLLEDHOSTFILE
fi
# Don't use wc -l to compute it to avoid issues with trailing \n at EOF
-hostfile_procs=$(grep -c "[a-zA-Z0-9]" $HOSTFILE)
-if [ ${hostfile_procs} = 0 ] ; then
- echo "[$(basename $0)] ** error: the hostfile '${HOSTFILE}' is empty. Aborting." >&2
+hostfile_procs=$(grep -c "[a-zA-Z0-9]" "$HOSTFILE")
+if [ "${hostfile_procs}" = 0 ] ; then
+ echo "[$(basename "$0")] ** error: the hostfile '${HOSTFILE}' is empty. Aborting." >&2
exit 1
fi
##-------------------------------- DEFAULT APPLICATION --------------------------------------
-APPLICATIONTMP=$(echo ${PROC_ARGS}|cut -d' ' -f2 -s)
+APPLICATIONTMP=$(echo "${PROC_ARGS}"|cut -d' ' -f2 -s)
-cat > ${APPLICATIONTMP} < "${APPLICATIONTMP}" <
APPLICATIONHEAD
##---- cache hostnames of hostfile---------------
-if [ -n "${HOSTFILE}" ] && [ -f ${HOSTFILE} ]; then
- hostnames=$(tr '\n\r' ' ' < ${HOSTFILE})
- NUMHOSTS=$(wc -l < ${HOSTFILE})
+if [ -n "${HOSTFILE}" ] && [ -f "${HOSTFILE}" ]; then
+ hostnames=$(tr '\n\r' ' ' < "${HOSTFILE}")
+ NUMHOSTS=$(wc -l < "${HOSTFILE}")
fi
-DESCRIPTIONFILE=$(echo $PROC_ARGS|cut -d' ' -f1)
+DESCRIPTIONFILE=$(echo "$PROC_ARGS"|cut -d' ' -f1)
if [ -n "${DESCRIPTIONFILE}" ] && [ -f "${DESCRIPTIONFILE}" ]; then
IFS_OLD=$IFS
- IFS=$'\n'
+ IFS=$(printf '\n_'); IFS=${IFS%_} # protect trailing \n
set -f
NUMPROCS=0
while IFS= read -r line; do
@@ -135,13 +135,13 @@ if [ -n "${DESCRIPTIONFILE}" ] && [ -f "${DESCRIPTIONFILE}" ]; then
instance=$(echo "$line"|cut -d' ' -f1)
hosttrace=$(tr '\n\r' ' ' < $(echo "$line"|cut -d' ' -f2))
NUMPROCSMINE=$(wc -l < $(echo "$line"|cut -d' ' -f2))
-
+
if [ $NUMPROCSMINE != $(echo "$line"|cut -d' ' -f3) ];
then
echo "declared num of processes for instance $instance : $(echo "$line"|cut -d' ' -f3) is not the same as the one in the replay files : $NUMPROCSMINE. Please check consistency of these information"
exit 1
fi
-
+
sleeptime=$(echo "$line"|cut -d' ' -f4)
HAVE_SEQ=$(which seq 2>/dev/null)
@@ -149,7 +149,7 @@ if [ -n "${DESCRIPTIONFILE}" ] && [ -f "${DESCRIPTIONFILE}" ]; then
SEQ1=$( ${HAVE_SEQ} 0 $(( NUMPROCSMINE - 1 )) )
else
cnt=0
- while (( cnt < NUMPROCSMINE )) ; do
+ while [ $(( cnt < NUMPROCSMINE )) -ne 0 ]; do
SEQ1="$SEQ1 $cnt"
cnt=$((cnt + 1))
done
@@ -168,45 +168,46 @@ if [ -n "${DESCRIPTIONFILE}" ] && [ -f "${DESCRIPTIONFILE}" ]; then
if [ -n "${HOSTFILE}" ]; then
j=$(( NUMPROCS % NUMHOSTS + 1))
fi
- hostname=$(echo $hostnames|cut -d' ' -f$j)
+ hostname=$(echo "$hostnames"|cut -d' ' -f$j)
if [ -z "${hostname}" ]; then
host="host"$($j)
else
host="${hostname}"
fi
-
- echo " " >> ${APPLICATIONTMP}
- echo " " >> ${APPLICATIONTMP}
- echo " " >> ${APPLICATIONTMP}
- echo " " >> ${APPLICATIONTMP}
-
- echo " " >> ${APPLICATIONTMP}
- echo " " >> ${APPLICATIONTMP}
+ {
+ echo " "
+ echo " "
+ echo " "
+ echo " "
+
+ echo " "
+ echo " "
+ } >> "${APPLICATIONTMP}"
NUMPROCS=$(( NUMPROCS + 1))
done
# return IFS back to newline for "for" loop
IFS_OLD=$IFS
- IFS=$'\n'
- done < ${DESCRIPTIONFILE}
+ IFS=$(printf '\n_'); IFS=${IFS%_} # protect trailing \n
+ done < "${DESCRIPTIONFILE}"
# return delimiter to previous value
IFS=$IFS_OLD
IFS_OLD=
else
- printf "File not found: %s\n", ${DESCRIPTIONFILE} >&2
+ printf "File not found: %s\n", "${DESCRIPTIONFILE}" >&2
exit 1
fi
-cat >> ${APPLICATIONTMP} <> "${APPLICATIONTMP}" <
APPLICATIONFOOT
##-------------------------------- end DEFAULT APPLICATION --------------------------------------
if [ ${HOSTFILETMP} = 1 ] ; then
- rm ${HOSTFILE}
+ rm "${HOSTFILE}"
fi
if [ ${UNROLLEDHOSTFILETMP} = 1 ] ; then
- rm ${UNROLLEDHOSTFILE}
+ rm "${UNROLLEDHOSTFILE}"
fi
exit 0