#!/usr/bin/env zsh
# vim:syn=zsh
# smburl.sh -- zsh script to open smb:// links on windows.
# Walter Doekes (C) 2005 -- License: Public Domain
ARGS="$*"
# Is it an smb:// link?
if [[ "${ARGS[0,4]}" != "smb:" ]] {
	print "Unsupported format; please provide an smb:// URI."
	print "\nHit [ENTER]."
	read x
	exit 1
}
# Change the URI from smb://server/share/dir/file to \\server\share\dir\file
REPLACED="$ARGS"
REPLACED="${REPLACED[5,-1]}"
REPLACED="${REPLACED:gs|/|\\\\|}"
# Run rundll with the file:// handler.
rundll32.exe url.dll,FileProtocolHandler "$REPLACED"
## Uncomment the lines below for diagnostics
#print "Tried to open:\n${REPLACED:gs/\\/\\\\\\\\/}\n\nHit [ENTER]."
#read x
