According to this I can get it using this command:
dscl . -read ~/ UserShell
So, I wrote this code using Qt
:
QProcess p;
p.setProcessChannelMode(QProcess::MergedChannels);
p.start("dscl", QStringList() << "." << "-read" << "~/" << "UserShell");
p.waitForFinished();
auto result = QString::fromUtf8(p.readAll());
But, the result
is empty. What am I doing wrong? This command works fine in the Terminal app.
Addition #1. This works, but it looks stupid :)
p.start("bash", QStringList() << "-c" << "dscl . -read ~/ UserShell")
CodePudding user response:
I think the only alternative is to expand the ~
yourself. So something like (untested)...
p.start("dscl", QStringList() << "." << "-read" << QDir::homePath() << "UserShell");