{"id":13782751,"url":"https://github.com/mrharmonies/hashpling","last_synced_at":"2025-05-11T16:32:31.684Z","repository":{"id":202485410,"uuid":"141584060","full_name":"mrharmonies/hashpling","owner":"mrharmonies","description":"hashpling allows you to use shebang on non-UNIX platform","archived":false,"fork":false,"pushed_at":"2021-09-23T22:39:14.000Z","size":207,"stargazers_count":11,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-04-24T15:34:20.245Z","etag":null,"topics":["dos","dosbox","freedos","hashpling","interpreter","linux","lua","nodejs","perl","python","ruby","shebang","unix","windows"],"latest_commit_sha":null,"homepage":"http://mrharmonies.github.io/hashpling","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mrharmonies.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-07-19T13:32:23.000Z","updated_at":"2023-12-31T22:52:42.000Z","dependencies_parsed_at":"2024-05-10T23:00:31.311Z","dependency_job_id":null,"html_url":"https://github.com/mrharmonies/hashpling","commit_stats":null,"previous_names":["mrharmonies/hashpling"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrharmonies%2Fhashpling","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrharmonies%2Fhashpling/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrharmonies%2Fhashpling/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrharmonies%2Fhashpling/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrharmonies","download_url":"https://codeload.github.com/mrharmonies/hashpling/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":213838092,"owners_count":15645778,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dos","dosbox","freedos","hashpling","interpreter","linux","lua","nodejs","perl","python","ruby","shebang","unix","windows"],"created_at":"2024-08-03T18:01:43.470Z","updated_at":"2024-08-03T18:10:48.369Z","avatar_url":"https://github.com/mrharmonies.png","language":"C","readme":"# hashpling\nHashpling allows you to **use shebang on non-unix platform**, (eg. on Windows 10, Windows XP, MSDOS, or Haiku). For more info about shebang, read this wikipedia article on [shebang](https://en.wikipedia.org/wiki/Shebang_(Unix)). Hashpling is **very fast** and **portable** because it is written in **C** and following **ANSI C** language dialect. \n\n# usage\nJust add **#!** followed by **path to interpreter** (works with many famous interpreter including **python, bash, kornshell, perl, lua, nodejs, ruby, gnuplot, instantfpc, etc**) at the very **beginning** of your file and continue writing your code below it. To execute the code, just run **'hp.exe *filename*'** on command line.\n\n![](https://drive.google.com/uc?id=19t10vXhu90PSn2uAnV0vr08ABcM79UPJ)\n\nTip: If you use windows, just add '.hp' file extension at the end of your filename and associate the extension with hashpling program. So later when you double click the dot-hp file, it will execute automatically. No execution permission is required. \n\nExample using python interpreter located in \"**c:\\python\\bin\\python32**\", append the path right after shebang, like this \"**#!c:\\python\\bin\\python32.exe**\":\n```python\n#!c:\\python\\bin\\python32.exe\nkmh = int(raw_input(\"Enter km/h: \"))\nmph =  0.6214 * kmh\nprint \"Speed:\", kmh, \"KM/H = \", mph, \"MPH\"\n```\nIf the interpreter in already in the folder registered in **PATH** environment variable, then full path is not required, in this case, just use \"**#!perl**\":\n```perl\n#!perl\nprint \"Hello, world!\\n\";\nprint qq=Did you say \"Hello?\"\\n=;\n```\nUsing hashpling on macOS, linux or other UNIX variant? Shebang is already in the heart of every UNIX system, but just to show hashpling works everywhere, heres another example that works on UNIX-like platform:\n```python\n#!/usr/bin/python\nfriends = ['john', 'pat', 'gary', 'michael']\nfor i, name in enumerate(friends):\n    print \"iteration {iteration} is {name}\".format(iteration=i, name=name)\n```\n```pascal\n#!instantfpc\n// instantfpc folder is registered in PATH environment variables, so full path is not required.\nprogram params;\nvar\n  i: Integer;\nbegin\n  for i:=0 to ParamCount do writeln(ParamStr(i));\nend.\n```\nEven using '**/usr/bin/env**' works!\n```bash\n#!/usr/bin/env bash\necho \"Hello world\"\n```\nPassing arguments to script is as usual, for example executing this script with \"**hp namearg.sh _audrey hepburn_**\" will produce this output\n```\n$ hp namearg.sh audrey hepburn\nMy first name is audrey\nMy surname is hepburn\nTotal number of arguments is 2\n```\nand here is the bash script (namearg.sh)\n```bash\n#!/bin/bash\n# example of using arguments to a script\necho \"My first name is $1\"\necho \"My surname is $2\"\necho \"Total number of arguments is $#\" \n```\nHashpling also forward **exit code** from the interpreter. So if you exit with certain exit code, you wont lose that data.\n\n![](https://drive.google.com/uc?id=1Q28gQPuiVlhdFpBzMGR9VTxNswIHkhPg)\n\nHashpling can also **run on a http server**. In this example I'm using **[tinyweb](https://www.ritlabs.com/en/products/tinyweb/)**. After placing this Lua script (named x.hp) in \"**cgi-bin**\":\n```lua\n#!C:\\www\\root\\cgi-bin\\lua53\n\nprint(\"Content-type: text/html\\n\\n\");\nprint(\"\u003cHTML\u003e\\n\");\nprint( \"\u003cHEAD\u003e\u003cTITLE\u003ehashpling on HTTP server!\u003c/TITLE\u003e\u003c/HEAD\u003e\\n\");\nprint(\"\u003cBODY\u003e\\n\");\nprint(\"\u003cH1\u003ehashpling running on HTTP server!\u003c/H1\u003e\u003cHR\u003e\\n\");\nprint(\"\u003c/BODY\u003e\u003c/HTML\u003e\\n\");\n```\nI can go to **http://localhost/cgi-bin/x.hp** in my favorite browser and get this result:\n\n![](https://drive.google.com/uc?id=1mayTKWP1ytebl8T2tfk-WzzHWMEPXsQs)\n\n# compiling\nHashpling is written in **C** and following **ANSI C** language dialect which makes it very fast and portable. Hashpling only use 2 standard C library headers (stdio.h and stdlib.h). To compile, change directory to \"src\" folder and just do standard compilation using your C compiler eg, **'gcc -ansi -o hp.exe hashpling.c'**. This compilation will produce **one self-contained** executable. The executable requires **no dependency**, so its very **portable**. Compilation is tested sucessfully on **Windows, DOS, macOS, Haiku and Ubuntu**.\n\n# binaries\nI recommend compiling hashpling from source. Compiling hashpling from source is easy if you already have C compiler installed in your system (see \"compiling\" part above). However you can download precompiled binaries (**unmaintained**) here:\n+ **Windows (Mingw32)** - \u003chttps://goo.gl/3AzZu2\u003e (v0.1) \n+ **macOS High Sierra (clang)** - \u003chttps://goo.gl/oeTA15\u003e (v0.1)\n+ **DOS/DOSBOX (djgpp)** - \u003chttps://goo.gl/NdztRB\u003e (v0.1)\n\n# more screenshot\n![](https://drive.google.com/uc?id=143BAvDgNTuEiYN8SP24b5y-AzvZz6Zm3)\n\n# license\n  Copyright (C) 2018 Mohd Kholid Yaacob (\u003chttp://mrharmonies.blogspot.com\u003e)\n  \n  This source is free software; you can redistribute it and/or modify it under\n  the terms of the GNU General Public License as published by the Free\n  Software Foundation; either version 2 of the License, or (at your option)\n  any later version.\n  \n  \n  This code is distributed in the hope that it will be useful, but WITHOUT ANY\n  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\n  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more\n  details.\n  \n  \n  A copy of the GNU General Public License is available on the World Wide Web\n  at \u003chttp://www.gnu.org/copyleft/gpl.html\u003e. You can also obtain it by writing\n  to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,\n  Boston, MA 02110-1335, USA. \n","funding_links":[],"categories":["C"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrharmonies%2Fhashpling","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrharmonies%2Fhashpling","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrharmonies%2Fhashpling/lists"}