|
24 | 24 | fi
|
25 | 25 |
|
26 | 26 | clone_command() {
|
27 |
| - if git clone "$clone_url" "$dir"; then |
| 27 | + if git clone -- "$clone_url" "$dir"; then |
28 | 28 | echo "Cloned Popcorn Time successfully"
|
29 | 29 | else
|
30 | 30 | echo "Popcorn Time encountered an error and could not be cloned"
|
31 | 31 | exit 2
|
32 | 32 | fi
|
33 | 33 | }
|
34 | 34 |
|
35 |
| -if [ -e ".git/config" ]; then |
36 |
| - dat="$(grep url .git/config)" |
| 35 | +git_dir="$(git rev-parse --git-dir 2>/dev/null)" || git_dir=".git" |
| 36 | +if [ -e "$git_dir"/config ]; then |
| 37 | + dat="$(grep -- url "$git_dir"/config)" |
37 | 38 | case "$dat" in *popcorn*)
|
38 | 39 | echo "You appear to be inside of a Popcorn Time repository already, not cloning"
|
39 | 40 | clone_repo="False"
|
| 41 | + cd -- "$(dirname "$git_dir")" # otherwise yarn build might fail |
40 | 42 | ;;
|
41 | 43 | *)
|
42 | 44 | try="True"
|
@@ -67,7 +69,7 @@ if [ -e ".git/config" ]; then
|
67 | 69 | fi
|
68 | 70 | if [ "$clone_repo" = "True" ]; then
|
69 | 71 | echo "Cloning Popcorn Time"
|
70 |
| - read -r -p "Where do you wish to clone Popcorn Time to? [popcorn] " dir |
| 72 | + read -p "Where do you wish to clone Popcorn Time to? [popcorn] " dir |
71 | 73 | if [ -z "$dir" ]; then
|
72 | 74 | dir='popcorn'
|
73 | 75 | elif [ "$dir" = "/" ]; then
|
@@ -98,7 +100,10 @@ if [ "$clone_repo" = "True" ]; then
|
98 | 100 | echo "Removing old directory"
|
99 | 101 | if [ "$dir" != "." ] || [ "$dir" != "$PWD" ]; then
|
100 | 102 | echo "Cleaning up from inside the destination directory"
|
101 |
| - rm -rf "$dir" |
| 103 | + if ! rm -rf -- "$dir"; then |
| 104 | + echo "Cannot delete the directory" |
| 105 | + exit 4 |
| 106 | + fi |
102 | 107 | fi
|
103 | 108 | clone_command
|
104 | 109 | else
|
|
110 | 115 | if [ -z "$dir" ]; then
|
111 | 116 | dir="."
|
112 | 117 | fi
|
113 |
| -cd "$dir" |
| 118 | + |
| 119 | +cd -- "$dir" |
| 120 | + |
114 | 121 | echo "Switched to $PWD"
|
115 | 122 |
|
116 | 123 | if [ "$rd_dep" = "yes" ]; then
|
|
124 | 131 |
|
125 | 132 | if yarn build; then
|
126 | 133 | echo "Popcorn Time built successfully!"
|
127 |
| - if [[ "$(uname -s)" != *"NT"* ]]; then # if not windows |
| 134 | + if [[ ! "$(uname -s)" =~ "NT" ]]; then # if not windows |
128 | 135 | ./Create-Desktop-Entry
|
129 | 136 | fi
|
130 | 137 | echo "Run 'yarn start' to launch the app or run Popcorn-Time from the ./build folder..."
|
|
0 commit comments