SU_XCLT_FLUG_PATH=/tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
if[ ! -f ${SU_XCLT_FLUG_PATH}]; then touch ${SU_XCLT_FLUG_PATH}fiXCLT_NAME=`softwareupdate -l | grep "Label: Command Line Tools" | awk -F': ''{print $2}'`if[ $? -ne 0]; then exit
fisoftwareupdate -i ${XCLT_NAME}if[ -f ${SU_XCLT_FLUG_PATH}]; then rm ${SU_XCLT_FLUG_PATH}fi
おまけ
以下はmacOSインストール直後の様子をメモしたもの。
1
2
$ which git
/usr/bin/git
1
2
3
4
$ git --version
xcode-select: note: No developer tools were found, requesting install.
If developer tools are located at a non-default location on disk, use `sudo xcode-select --switch path/to/Xcode.app` to specify the Xcode that you wish to use for command line developer tools, and cancel the installation dialog.
See `man xcode-select`for more details.
1
2
$ which make
/usr/bin/make
1
2
3
4
$ make --version
xcode-select: note: No developer tools were found, requesting install.
If developer tools are located at a non-default location on disk, use `sudo xcode-select --switch path/to/Xcode.app` to specify the Xcode that you wish to use for command line developer tools, and cancel the installation dialog.
See `man xcode-select`for more details.
1
2
$ which gnumake
/usr/bin/gnumake
1
2
3
4
$ gnumake --version
xcode-select: note: No developer tools were found, requesting install.
If developer tools are located at a non-default location on disk, use `sudo xcode-select --switch path/to/Xcode.app` to specify the Xcode that you wish to use for command line developer tools, and cancel the installation dialog.
See `man xcode-select`for more details.
$ perl --version
This is perl 5, version 30, subversion 3(v5.30.3) built for darwin-thread-multi-2level
(with 2 registered patches, see perl -V for more detail)Copyright 1987-2020, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl". If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.
1
2
$ which python
python not found
1
2
$ which swift
/usr/bin/swift
1
2
3
4
$ swift --version
xcode-select: note: No developer tools were found, requesting install.
If developer tools are located at a non-default location on disk, use `sudo xcode-select --switch path/to/Xcode.app` to specify the Xcode that you wish to use for command line developer tools, and cancel the installation dialog.
See `man xcode-select`for more details.
1
2
$ which swiftc
/usr/bin/swiftc
1
2
3
4
$ swiftc --version
xcode-select: note: No developer tools were found, requesting install.
If developer tools are located at a non-default location on disk, use `sudo xcode-select --switch path/to/Xcode.app` to specify the Xcode that you wish to use for command line developer tools, and cancel the installation dialog.
See `man xcode-select`for more details.