0

I have troubles with whitespaces and command substitution. I made a tiny script to show the problem:

#! /bin/bash

a="toilet -t  --font='Dot Matrix' --filter metal --filter border ABC"
#a="find . -type f -name \"hello world\""

log_error=$($a 2>&1)
if [ $? -ne 0 ]
then
    echo "$a"
    echo "$log_error"
    exit 1
fi
tres.14159
  • 234
  • 1
  • 2
  • 6
  • 2
    It's likely not the command substitution that's the problem here, it's the expansion of `$a` - put the arguments in an array instead of a single string. See [How can we run a command stored in a variable?](https://unix.stackexchange.com/questions/444946/how-can-we-run-a-command-stored-in-a-variable) – steeldriver Apr 08 '22 at 11:36
  • With `eval` fix me problem. Thanks for the link. – tres.14159 Apr 08 '22 at 13:28
  • `eval` is definitely not the solution you should have taken from that link – jesse_b Apr 08 '22 at 16:32

0 Answers0