0

i have bash script where i am trying to zip files, on my windows i am using git bash to execute the script, following is my script

  #!/bin/bash
  cd src/lambda/api_gw_authorizer/
  zip -r src/lambda/api_gw_authorizer/api_gw_authorizer.py /src/lambda/api_gw_authorizer
  aws lambda update-function-code --function-name api_gw_authorizer-sam --zip-file fileb://api_gw_authorizer.zip

I get this error

Command Line Error:
Unsupported command:
C:/Program Files/Git/src/lambda/api_gw_authorizer/api_gw_authorizer.py

for some reason the script is taking me to the git installation.

noobie-php
  • 6,817
  • 15
  • 54
  • 101
  • the new archive file name must set as first parameter: *zip -r zipfile [file ...]* (see '*zip --help'*) and you already `cd` into folder where the path `src` doesn't exist, or `/src` doesn't exist (which one is right)? – alecxs Jun 05 '20 at 11:23
  • @alecxs ok, so i updated it following `zip -r api_gw_authorizer.zip src/lambda/api_gw_authorizer/api_gw_authorizer.py /src/lambda/api_gw_authorizer` still same issue – noobie-php Jun 05 '20 at 11:23
  • give zip the right path to file (or folder, not both) and spaces in names require quoting or escaping – alecxs Jun 05 '20 at 11:29

1 Answers1

0

Git Bash on Windows does not include zip. See How to add man and zip to "git bash" installation on Windows for ways to install zip as a command on Windows.

If you want to zip files without needing to install any additional tools on Windows, in a way that works both on git bash and on other *nix systems, you might be able to use perl.

Per Josip Medved's blog, the following script creates an .epub (which is a zip file), and includes a filter for stripping src/ from the files added to the zip:

perl -e '
  use strict;
  use warnings;
  use autodie;
  use IO::Compress::Zip qw(:all);
  zip [
    "src/mimetype",
    <"src/META-INF/*.*">,
    <"src/OEBPS/*.*">,
    <"src/OEBPS/chapters/*.*">
  ] => "bin/book.epub",
       FilterName => sub { s[^src/][] },
       Zip64 => 0,
  or die "Zip failed: $ZipError\n";
'
Marc Durdin
  • 1,675
  • 2
  • 20
  • 27