Replace ` ` with $( ) inside strings and in commands (#77)

* Changed how to execute shell commands inside output strings

* Removed the extra { }

* Drop changes to JSON files inside lib/json
pull/83/head
Abdelkafi Ahmed 7 years ago committed by Joseph Werle
parent c1f0cd3664
commit 0617f26461

1
.gitignore vendored

@ -1 +0,0 @@
deps

@ -9,7 +9,7 @@ usage () {
## Read a package property
bpkg_getdeps () {
local cwd="`pwd`"
local cwd="$(pwd)"
local pkg="${cwd}/package.json"
## parse flags
@ -22,7 +22,7 @@ bpkg_getdeps () {
## ensure there is a package to read
if ! test -f "${pkg}"; then
echo 2>&1 "error: Unable to find \`package.json' in `pwd`"
echo 2>&1 "error: Unable to find \`package.json' in $(pwd)"
return 1
fi

@ -67,7 +67,7 @@ append () {
appendf () {
local fmt="$1"
shift
buf+="`printf "${fmt}" "${@}"`"
buf+="$(printf "${fmt}" "${@}")"
}
## wraps each argument in quotes
@ -91,7 +91,7 @@ intro () {
}
options () {
opt NAME "$(basename `pwd`)"
opt NAME "$(basename $(pwd))"
opt VERSION "0.0.1"
opt DESCRIPTION ""
opt GLOBAL ""
@ -120,7 +120,8 @@ required () {
"SCRIPTS"
do
eval local val="\${${key}}"
[ -z "${val}" ] && error "Missing \`${key}' property"
[ -z "${val}" ] && error "Missing \`
${key}' property"
done
}
@ -270,7 +271,7 @@ create_repo () {
## main
bpkg_init () {
local version="0.0.1"
local cwd="`pwd`"
local cwd="$(pwd)"
local buf="" ## output buffer
local file="${cwd}/package.json" ## output file
local arg="$1"

@ -4,6 +4,8 @@
"description": "Initialize a bpkg package.json",
"global": "true",
"install": "make install",
"scripts": [ "bpkg-init.sh" ]
"scripts": [
"bpkg-init.sh"
]
}

@ -254,14 +254,14 @@ bpkg_install_from_remote () {
url="${remote}${uri}"
repo_url=$git_remote/$user/$name.git
## determine if `package.json' exists at url
## determine if 'package.json' exists at url
{
status=$(curl $auth_param -sL "${url}/package.json?`date +%s`" -w '%{http_code}' -o /dev/null)
status=$(curl $auth_param -sL "${url}/package.json?$(date +%s)" -w '%{http_code}' -o /dev/null)
if [ "0" != "$?" ] || (( status >= 400 )); then
warn "package.json doesn't exist"
has_pkg_json=0
# check to see if there's a Makefile. If not, this is not a valid package
status=$(curl $auth_param -sL "${url}/Makefile?`date +%s`" -w '%{http_code}' -o /dev/null)
status=$(curl $auth_param -sL "${url}/Makefile?$(date +%s)" -w '%{http_code}' -o /dev/null)
if [ "0" != "$?" ] || (( status >= 400 )); then
warn "Makefile not found, skipping remote: $url"
return 1
@ -270,10 +270,10 @@ bpkg_install_from_remote () {
}
## read package.json
json=$(curl $auth_param -sL "${url}/package.json?`date +%s`")
json=$(curl $auth_param -sL "${url}/package.json?$(date +%s)")
if (( 1 == $has_pkg_json )); then
## get package name from `package.json'
## get package name from 'package.json'
name="$(
echo -n ${json} |
bpkg-json -b |
@ -356,10 +356,10 @@ bpkg_install_from_remote () {
## copy package.json over
curl $auth_param -sL "${url}/package.json" -o "${cwd}/deps/${name}/package.json"
## make `deps/' directory if possible
## make 'deps/' directory if possible
mkdir -p "${cwd}/deps/${name}"
## make `deps/bin' directory if possible
## make 'deps/bin' directory if possible
mkdir -p "${cwd}/deps/bin"
# install package dependencies

@ -6,7 +6,7 @@ if ! type -f bpkg-utils &>/dev/null; then
echo "error: bpkg-utils not found, aborting"
exit 1
else
source `which bpkg-utils`
source $(which bpkg-utils)
fi
bpkg_initrc

@ -10,7 +10,7 @@ usage () {
## Read a package property
bpkg_package () {
local prop="${1}"
local cwd="`pwd`"
local cwd="$(pwd)"
local pkg="${cwd}/package.json"
## parse flags
@ -23,7 +23,7 @@ bpkg_package () {
## ensure there is a package to read
if ! test -f "${pkg}"; then
echo 2>&1 "error: Unable to find \`package.json' in `pwd`"
echo 2>&1 "error: Unable to find \`package.json' in $(pwd)"
return 1
fi
@ -35,7 +35,7 @@ bpkg_package () {
}
else
## show value for a specific property
## in `package.json'
## in 'package.json'
{
cat "${pkg}" | bpkg-json -b | grep "${prop}" | awk '{ $1=""; printf $0 }'
echo

@ -6,7 +6,7 @@ if ! type -f bpkg-utils &>/dev/null; then
echo "error: bpkg-utils not found, aborting"
exit 1
else
source `which bpkg-utils`
source $(which bpkg-utils)
fi
bpkg_initrc
@ -57,8 +57,8 @@ show_package () {
uri=$BPKG_REMOTE/$pkg/raw/master
fi
json=$(eval "curl $auth -sL '$uri/package.json?`date +%s`'")
readme=$(eval "curl $auth -sL '$uri/README.md?`date +%s`'")
json=$(eval "curl $auth -sL '$uri/package.json?$(date +%s)'")
readme=$(eval "curl $auth -sL '$uri/README.md?$(date +%s)'")
local readme_len=$(echo "$readme" | wc -l | tr -d ' ')
@ -96,9 +96,9 @@ show_package () {
OLDIFS="$IFS"
IFS=$'\n'
for src in $(echo "$sources"); do
local http_code=$(eval "curl $auth -sL '$uri/$src?`date +%s`' -w '%{http_code}' -o /dev/null")
local http_code=$(eval "curl $auth -sL '$uri/$src?$(date +%s)' -w '%{http_code}' -o /dev/null")
if (( http_code < 400 )); then
local content=$(eval "curl $auth -sL '$uri/$src?`date +%s`'")
local content=$(eval "curl $auth -sL '$uri/$src?$(date +%s)'")
echo "#[$src]"
echo "$content"
echo "#[/$src]"

@ -2,6 +2,8 @@
"name": "suggest",
"version": "0.0.2",
"description": "Suggest a command based on a query found in $PATH",
"scripts": [ "suggest.sh" ],
"scripts": [
"suggest.sh"
],
"install": "make install"
}

@ -2,6 +2,8 @@
"name": "term",
"version": "0.0.1",
"description": "Terminal utility functions",
"scripts": [ "term.sh" ],
"scripts": [
"term.sh"
],
"install": "make install"
}

@ -6,7 +6,7 @@ if ! type -f bpkg-utils &>/dev/null; then
echo "error: bpkg-utils not found, aborting"
exit 1
else
source `which bpkg-utils`
source $(which bpkg-utils)
fi
bpkg_initrc

Loading…
Cancel
Save