neo33
neo33

Reputation: 1879

How to use this function with ksh?

I have the following function written in bash:

msend() { f=$(mktemp) ; rm -f $f ; if [ "$#" -gt 1 ] ; then ; d_zip=true ; zip $f "$@";filename="$f.zip" ; uuencode $f $filename | mail  -s "$filename" $mail_addr ; else ; uuencode $1 $1 | mail  -s "$1" $mail_addr ; fi ; }

this function works really well but the problem is that is written in bash, there are some terminals that only allow the usage of ksh I would like to translate this function to ksh, I would like to appreciate any help to overcome this situation.

I order to be more clear to use this function first you have to declare the following variable with your email:

mail_addr=YOUR_EMAIL_ADDRESS.

Upvotes: 0

Views: 47

Answers (1)

bishop
bishop

Reputation: 39434

Doesn't crash in KSH 93u+:

msend() {
  f=$(mktemp)
  rm -f "$f"
  if [ "$#" -gt 1 ]; then
    d_zip=true
    zip "$f" "$@"
    filename="$f.zip"
    uuencode "$f" "$filename" | mail  -s "$filename" "$mail_addr"
  else
    uuencode "$1 $1" | mail  -s "$1" "$mail_addr"
  fi
}

The only oddities in your original post were spurious ;. If this fails, it's related to the commands and arguments, not the syntax.

Upvotes: 1

Related Questions