diff --git a/CHANGELOG.md b/CHANGELOG.md index b29c3ff9..52569a51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file automatically by Versionist. DO NOT EDIT THIS FILE MANUALLY! This project adheres to [Semantic Versioning](http://semver.org/). +## v5.2.9 - 2017-12-09 + +* Fix: Remove the final usage of perl from darwin.sh #238 [Andrew Scheller] + ## v5.2.8 - 2017-12-08 * Chore: pip on Travis OSX is now pip2 #239 [Andrew Scheller] diff --git a/lib/scripts.json b/lib/scripts.json index b165a15d..0beda6b2 100644 --- a/lib/scripts.json +++ b/lib/scripts.json @@ -1,6 +1,6 @@ { "darwin": { - "content": "#!/bin/bash\n\nset -u\nset -e\n\nget_key() {\n\n # This expression is intentionally unquoted so that\n # multiple lines get joined as a single one.\n # See https://github.com/resin-io-modules/drivelist/pull/129\n echo $(grep \"$1\" | awk -F \" +\" '{ print $3 }')\n\n}\n\nget_until_paren() {\n awk 'match($0, \"\\\\(|$\"){ print substr($0, 0, RSTART - 1) }'\n}\n\nDISKS=\"$(diskutil list | grep '^\\/' | get_until_paren)\"\nmount_output=\"$(mount)\"\n\nfor disk in $DISKS; do\n\n # Ignore drives that were just unplugged\n if ! diskinfo=\"$(diskutil info \"$disk\")\"; then\n continue\n fi\n\n device=\"$(echo \"$diskinfo\" | get_key \"Device Node\")\"\n\n # See http://superuser.com/q/631592\n raw_device=\"${device//disk/rdisk}\"\n\n description=\"$(echo \"$diskinfo\" | get_key \"Device / Media Name\")\"\n volume_name=\"$(echo \"$diskinfo\" | get_key \"Volume Name\")\"\n removable=\"$(echo \"$diskinfo\" | get_key \"Removable Media\")\"\n protected=\"$(echo \"$diskinfo\" | get_key \"Read-Only Media\")\"\n location=\"$(echo \"$diskinfo\" | get_key \"Device Location\")\"\n size=\"$(echo \"$diskinfo\" | sed 's/Disk Size/Total Size/g' | get_key \"Total Size\" | cut -d '(' -f 2 | cut -d ' ' -f 1)\"\n\n mountpoints=\"$(echo \"$mount_output\" | perl -n -e'm{^'\"${disk}\"'(s[0-9]+)? on (.*) \\(.*\\)$} && print \"$2\\n\"')\"\n\n # Omit mounted DMG images\n if [[ \"$description\" == \"Disk Image\" ]]; then\n continue\n fi\n\n echo \"device: $device\"\n echo \"displayName: $device\"\n\n if [[ $volume_name =~ .*Not\\ applicable.* ]]; then\n echo \"description: \\\"$description\\\"\"\n else\n echo \"description: \\\"$volume_name - $description\\\"\"\n fi\n\n echo \"size: $size\"\n\n if [[ -z \"$mountpoints\" ]]; then\n echo \"mountpoints: []\"\n else\n echo \"mountpoints:\"\n echo \"$mountpoints\" | while read -r mountpoint ; do\n echo \" - path: \\\"$mountpoint\\\"\"\n done\n fi\n\n echo \"raw: $raw_device\"\n\n if [[ \"$protected\" == \"Yes\" ]]; then\n echo \"protected: True\"\n else\n echo \"protected: False\"\n fi\n\n if [[ \"$device\" == \"/dev/disk0\" ]] || \\\n [[ ( \"$removable\" == \"No\" ) || (\"$removable\" == \"Fixed\") ]] || \\\n [[ ( \"$location\" =~ \"Internal\" ) && ( \"$removable\" != \"Yes\" ) && ( \"$removable\" != \"Removable\" ) ]] || \\\n echo \"$mountpoints\" | grep \"^/$\"\n then\n echo \"system: True\"\n else\n echo \"system: False\"\n fi\n\n echo \"\"\ndone\n", + "content": "#!/bin/bash\n\nset -u\nset -e\n\nget_key() {\n\n # This expression is intentionally unquoted so that\n # multiple lines get joined as a single one.\n # See https://github.com/resin-io-modules/drivelist/pull/129\n echo $(grep \"$1\" | awk -F \" +\" '{ print $3 }')\n\n}\n\nget_until_paren() {\n awk 'match($0, \"\\\\(|$\"){ print substr($0, 0, RSTART - 1) }'\n}\n\nDISKS=\"$(diskutil list | grep '^\\/' | get_until_paren)\"\nmount_output=\"$(mount)\"\n\nfor disk in $DISKS; do\n\n # Ignore drives that were just unplugged\n if ! diskinfo=\"$(diskutil info \"$disk\")\"; then\n continue\n fi\n\n device=\"$(echo \"$diskinfo\" | get_key \"Device Node\")\"\n\n # See http://superuser.com/q/631592\n raw_device=\"${device//disk/rdisk}\"\n\n description=\"$(echo \"$diskinfo\" | get_key \"Device / Media Name\")\"\n volume_name=\"$(echo \"$diskinfo\" | get_key \"Volume Name\")\"\n removable=\"$(echo \"$diskinfo\" | get_key \"Removable Media\")\"\n protected=\"$(echo \"$diskinfo\" | get_key \"Read-Only Media\")\"\n location=\"$(echo \"$diskinfo\" | get_key \"Device Location\")\"\n size=\"$(echo \"$diskinfo\" | sed 's/Disk Size/Total Size/g' | get_key \"Total Size\" | cut -d '(' -f 2 | cut -d ' ' -f 1)\"\n\n mountpoints=\"$(echo \"$mount_output\" | grep -E \"^${disk}(s[0-9]+)? on \" | cut -d ' ' -f 3)\"\n\n # Omit mounted DMG images\n if [[ \"$description\" == \"Disk Image\" ]]; then\n continue\n fi\n\n echo \"device: $device\"\n echo \"displayName: $device\"\n\n if [[ $volume_name =~ .*Not\\ applicable.* ]]; then\n echo \"description: \\\"$description\\\"\"\n else\n echo \"description: \\\"$volume_name - $description\\\"\"\n fi\n\n echo \"size: $size\"\n\n if [[ -z \"$mountpoints\" ]]; then\n echo \"mountpoints: []\"\n else\n echo \"mountpoints:\"\n echo \"$mountpoints\" | while read -r mountpoint ; do\n echo \" - path: \\\"$mountpoint\\\"\"\n done\n fi\n\n echo \"raw: $raw_device\"\n\n if [[ \"$protected\" == \"Yes\" ]]; then\n echo \"protected: True\"\n else\n echo \"protected: False\"\n fi\n\n if [[ \"$device\" == \"/dev/disk0\" ]] || \\\n [[ ( \"$removable\" == \"No\" ) || (\"$removable\" == \"Fixed\") ]] || \\\n [[ ( \"$location\" =~ \"Internal\" ) && ( \"$removable\" != \"Yes\" ) && ( \"$removable\" != \"Removable\" ) ]] || \\\n echo \"$mountpoints\" | grep \"^/$\"\n then\n echo \"system: True\"\n else\n echo \"system: False\"\n fi\n\n echo \"\"\ndone\n", "originalFilename": "darwin.sh", "type": "text" }, @@ -9,4 +9,4 @@ "originalFilename": "linux.sh", "type": "text" } -} +} \ No newline at end of file diff --git a/package.json b/package.json index 7d6fe548..73cfd6de 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "drivelist", - "version": "5.2.8", + "version": "5.2.9", "description": "List all connected drives in your computer, in all major operating systems", "main": "lib/drivelist.js", "homepage": "https://github.com/resin-io-modules/drivelist", diff --git a/scripts/darwin.sh b/scripts/darwin.sh index b88a16be..fcbc93a3 100755 --- a/scripts/darwin.sh +++ b/scripts/darwin.sh @@ -38,7 +38,7 @@ for disk in $DISKS; do location="$(echo "$diskinfo" | get_key "Device Location")" size="$(echo "$diskinfo" | sed 's/Disk Size/Total Size/g' | get_key "Total Size" | cut -d '(' -f 2 | cut -d ' ' -f 1)" - mountpoints="$(echo "$mount_output" | perl -n -e'm{^'"${disk}"'(s[0-9]+)? on (.*) \(.*\)$} && print "$2\n"')" + mountpoints="$(echo "$mount_output" | grep -E "^${disk}(s[0-9]+)? on " | cut -d ' ' -f 3)" # Omit mounted DMG images if [[ "$description" == "Disk Image" ]]; then