I am working on a script to add and remove samba shares in linux. This script requires samba and dialog installed.
My complete code is at https://paste.ubuntu.com/p/Q45fjcFbwr/
Here's a snippet.
#!/bin/bash
function display_output() {
    dialog --backtitle "" --title "" --clear --msgbox "$1" 10 90
}
function execute() {
    execmd=("$1")
    ${execmd[@]}                   # doesn't do anything it seems...
    #display_output "${execmd[@]}"
}
function yesno() {
    # store command string
    cmd=$1
    
    dialog --title "Confirm" \
       --backtitle "Confirm command" \
       --yesno "$cmd" 7 90
    confirm=$?
    
    # actions
    case $confirm in
    0) execute "$cmd";;
    1) break;;
    255) break;;
    esac
}    
function create_share() {
    ...
    if [ $cancelled = "no" ]; then
    case $1 in
    PUBW) yesno "net usershare add \"${VALUES_ARRAY[0]}\" \"${VALUES_ARRAY[1]}\" \"${VALUES_ARRAY[2]}\" Everyone:F guest_ok=y && chmod 777 \"${VALUES_ARRAY[1]}\"";;
    PUBR) yesno "net usershare add \"${VALUES_ARRAY[0]}\" \"${VALUES_ARRAY[1]}\" \"${VALUES_ARRAY[2]}\" Everyone:R guest_ok=y";;
    PRVW) yesno "net usershare add \"${VALUES_ARRAY[0]}\" \"${VALUES_ARRAY[1]}\" \"${VALUES_ARRAY[2]}\" Everyone:F guest_ok=n && chmod 777 \"${VALUES_ARRAY[1]}\"";;
    PRVR) yesno "net usershare add \"${VALUES_ARRAY[0]}\" \"${VALUES_ARRAY[1]}\" \"${VALUES_ARRAY[2]}\" Everyone:R guest_ok=n";;
    esac
    fi
}
# try out main menu
# the main menu is in an infinite loop
...
Inside execute(), display_output "${execmd[@]}" correctly displays the command in string form in a msgbox.
But, ${execmd[@]} doesn't seem to do anything when I expect it to actually execute the command.
Thanks
