Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Prefixed output functions with 'print-'.

  • Loading branch information...
commit f724aa2444c4589fad3538ba6d86191ff3a89593 1 parent 76b1d5c
@sorin-ionescu authored
View
22 install-gcc-without-xcode
@@ -10,12 +10,12 @@ script_version='1.0.1'
cached_argv="${argv}"
# Writes to standard error.
-function error() {
+function print-error() {
echo "${script_name}: ${@}" >&2
}
# Writes to standard output.
-function info() {
+function print-info() {
echo "${@}" >&1
}
@@ -56,7 +56,7 @@ while [[ "${1}" == -* ]]; do
break
;;
( -* )
- error "invalid option: ${1}"
+ print-error "invalid option: ${1}"
help
exit 0
;;
@@ -65,19 +65,19 @@ done
# Get archive.
if (( ${#} < 1 )); then
- error "No archive given."
+ print-error "No archive given."
help
exit 1
else
if [[ ! -e "${1}" ]]; then
- error "Archive '${1}' does not exist."
+ print-error "Archive '${1}' does not exist."
help
exit 1
else
archive="$(cd "${1:h}" && pwd)/${1:t}"
if [[ "${archive}" == *.xz ]]; then
if (( ! ${+commands[xzcat]} )); then
- error "Cannot extract '${archive}' because XZ Utils are not installed."
+ print-error "Cannot extract '${archive}' because XZ Utils are not installed."
exit 1
else
decompressor='xzcat'
@@ -91,11 +91,11 @@ fi
# Get directory.
if (( ${#} < 1 )); then
- error "No directory given, assuming /."
+ print-error "No directory given, assuming /."
directory='/'
else
if [[ ! -e "${1}" ]]; then
- error "Directory '${1}' does not exist."
+ print-error "Directory '${1}' does not exist."
help
exit 1
else
@@ -106,13 +106,13 @@ fi
# Root is required to install.
if [[ ! -w "${directory}" ]]; then
- error "${script_name} requires root privileges. Running sudo..."
+ print-error "${script_name} requires root privileges. Running sudo..."
exec sudo "${0}" "${cached_argv[@]}"
exit ${?}
fi
-info "Installing:"
-info " ${archive}"
+print-info "Installing:"
+print-info " ${archive}"
cd "${directory}" \
&& "${decompressor}" < "${archive}" \
| cpio -idm 2> /dev/null
View
40 make-gcc-without-xcode
@@ -25,12 +25,12 @@ function cd() {
}
# Writes to standard error.
-function error() {
+function print-error() {
echo "${script_name}: ${@}" >&2
}
# Writes to standard output.
-function info() {
+function print-info() {
echo "${@}" >&1
}
@@ -71,7 +71,7 @@ while [[ "${1}" == -* ]]; do
break
;;
( -* )
- error "invalid option: ${1}"
+ print-error "invalid option: ${1}"
help
exit 1
;;
@@ -80,14 +80,14 @@ done
# Root is required to preserve permissions.
if (( ${EUID} != 0 )); then
- error "${script_name} requires root privileges. Running sudo..."
+ print-error "${script_name} requires root privileges. Running sudo..."
exec sudo "${0}" "${@}"
exit "${?}"
fi
# Make sure the xcode_installer is not missing before continuing.
if [[ ! -d "${xcode_installer}" ]]; then
- error "'${xcode_installer}' not found."
+ print-error "'${xcode_installer}' not found."
exit 1
fi
@@ -117,7 +117,7 @@ packages=(
# Make sure packages are not missing before continuing.
for package in "${packages[@]}"; do
if [[ ! -e "${xcode_installer_packages}/${package}" ]]; then
- error "Package '${package}' is missing. Xcode Installer is corrupt."
+ print-error "Package '${package}' is missing. Xcode Installer is corrupt."
exit 1
fi
done
@@ -144,9 +144,9 @@ payload_file_dir="$( mktemp -d -t "${script_name}" )"
payload_data_dir="$( mktemp -d -t "${script_name}" )"
package_merge_dir="$( mktemp -d -t "${script_name}" )"
-info "Extracting:"
+print-info "Extracting:"
for package in "${packages[@]}"; do
- info " ${package}"
+ print-info " ${package}"
# Set full path to package.
package_path="${xcode_installer_packages}/${package}"
@@ -181,8 +181,8 @@ for package in "${packages[@]}"; do
done
# Homebrew needs to know the Xcode version.
-info 'Generating:'
-info ' Dummy Xcode Files'
+print-info 'Generating:'
+print-info ' Dummy Xcode Files'
xcodebuild_file="${package_merge_dir}/usr/bin/xcodebuild"
cat <<-END
#!/bin/sh
@@ -191,8 +191,8 @@ END > "${xcodebuild_file}"
chmod 755 "${xcodebuild_file}"
# Do not overwrite existing files.
-info 'Purging:'
-info ' Existing Files'
+print-info 'Purging:'
+print-info ' Existing Files'
( cd "${package_merge_dir}" || exit
# Find all files and replace './' with '/'.
for existing_file in "$(find . ! -type d | sed -e 's:^\.::g')"; do
@@ -202,8 +202,8 @@ info ' Existing Files'
fi
done )
-info 'Configuring:'
-info ' Xcode Directory Path'
+print-info 'Configuring:'
+print-info ' Xcode Directory Path'
# Xcode root is now /, not /Developer (can be set with xcode-select).
if [[ -f "${package_merge_dir}/usr/share/xcode-select/xcode_dir_path" ]]; then
echo '/' > "${package_merge_dir}/usr/share/xcode-select/xcode_dir_path"
@@ -218,8 +218,8 @@ else
compressor='gzip'
fi
-info "Archiving:"
-info " ${archive}"
+print-info "Archiving:"
+print-info " ${archive}"
# Do not archive the directory, only the contents,
# or risk having tar change / permissions,
@@ -230,8 +230,8 @@ info " ${archive}"
| cpio -0o 2> /dev/null \
| "${compressor}" -9 > "${archive}" )
-info 'Purging:'
-info ' Temporary Files'
+print-info 'Purging:'
+print-info ' Temporary Files'
rm -rf "${payload_file_dir}" "${payload_data_dir}" "${package_merge_dir}"
if [[ "${archive}" == *.xz ]]; then
@@ -240,6 +240,6 @@ else
decompressor='gzcat'
fi
-info 'Install:'
-info " cd / && "${decompressor}" < '${archive}' | sudo cpio -idmv"
+print-info 'Install:'
+print-info " cd / && "${decompressor}" < '${archive}' | sudo cpio -idmv"
View
26 uninstall-gcc-without-xcode
@@ -10,12 +10,12 @@ script_version='1.0.1'
cached_argv="${argv}"
# Writes to standard error.
-function error() {
+function print-error() {
echo "${script_name}: ${@}" >&2
}
# Writes to standard output.
-function info() {
+function print-info() {
echo "${@}" >&1
}
@@ -56,7 +56,7 @@ while [[ "${1}" == -* ]]; do
break
;;
( -* )
- error "invalid option: ${1}"
+ print-error "invalid option: ${1}"
help
exit 0
;;
@@ -65,19 +65,19 @@ done
# Get archive.
if (( ${#} < 1 )); then
- error "No archive given."
+ print-error "No archive given."
help
exit 1
else
if [[ ! -e "${1}" ]]; then
- error "Archive '${1}' does not exist."
+ print-error "Archive '${1}' does not exist."
help
exit 1
else
archive="$(cd "${1:h}" && pwd)/${1:t}"
if [[ "${archive}" == *.xz ]]; then
if (( ! ${+commands[xzcat]} )); then
- error "Cannot extract '${archive}' because XZ Utils are not installed."
+ print-error "Cannot extract '${archive}' because XZ Utils are not installed."
exit 1
else
decompressor='xzcat'
@@ -91,11 +91,11 @@ fi
# Get directory.
if (( ${#} < 1 )); then
- error "No directory given, assuming /."
+ print-error "No directory given, assuming /."
directory='/'
else
if [[ ! -e "${1}" ]]; then
- error "Directory '${1}' does not exist."
+ print-error "Directory '${1}' does not exist."
help
exit 1
else
@@ -106,7 +106,7 @@ fi
# Root is required to uninstall.
if [[ ! -w "${directory}" ]]; then
- error "${script_name} requires root privileges. Running sudo..."
+ print-error "${script_name} requires root privileges. Running sudo..."
exec sudo "${0}" "${cached_argv[@]}"
exit ${?}
fi
@@ -117,8 +117,8 @@ directories="$(mktemp -t uninstall-gcc-without-xcode.directories)"
# Change CWD to installation directory.
cd "${directory}"
-info 'Purging:'
-info ' Files'
+print-info 'Purging:'
+print-info ' Files'
while read item; do
if [[ -L "${item}" ]]; then
unlink "${item}"
@@ -131,7 +131,7 @@ while read item; do
fi
done < <( "${decompressor}" < "${archive}" | cpio -it 2> /dev/null | sed -e 's:/*$::g' )
-info ' Directories'
+print-info ' Directories'
while read item; do
ds_store="${item}/.DS_Store"
if [[ -f "${ds_store}" ]]; then
@@ -143,6 +143,6 @@ while read item; do
fi
done < "${directories}"
-info ' Temporary Files'
+print-info ' Temporary Files'
rm "${directories}"
Please sign in to comment.
Something went wrong with that request. Please try again.